[buddypress-trac] [BuddyPress Trac] #6302: Add callbacks/events when ajax functions have finished
    buddypress-trac 
    noreply at wordpress.org
       
    Thu Mar 19 00:36:15 UTC 2015
    
    
  
#6302: Add callbacks/events when ajax functions have finished
---------------------------------+------------------------------
 Reporter:  Bowromir             |       Owner:
     Type:  enhancement          |      Status:  new
 Priority:  normal               |   Milestone:  Awaiting Review
Component:  Component - Any/All  |     Version:
 Severity:  normal               |  Resolution:
 Keywords:                       |
---------------------------------+------------------------------
Comment (by sbrajesh):
 Hi modemlooper,
 Here is the code example
 {{{
    jQuery( document ).ajaxComplete( function( evt, xhr, options ) {
        var action = get_var_in_query( 'action', options.data ) ;
        //switch
        switch( action ){
            case 'post_update':
                console.log('Activity was posted');
                break;
        }
    });
    function get_var_in_query( item,  str ){
        var items;
        if( !str )
            return false;
        var data_fields = str.split('&');
        for( var i=0; i< data_fields.length; i++ ){
            items = data_fields[i].split('=');
            if( items[0] == item )
                return items[1];
        }
        return false;
    }
 }}}
 I am using a helper function 'get_var_in_query' to find an item in the
 query string.
 The above example should log into the console when the the activity is
 posted and a response is returned.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6302#comment:9>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
    
    
More information about the buddypress-trac
mailing list