Skip to content

Instantly share code, notes, and snippets.

@modemlooper
Created March 19, 2015 01:56
Show Gist options
  • Select an option

  • Save modemlooper/6a6f8c15536c916da40f to your computer and use it in GitHub Desktop.

Select an option

Save modemlooper/6a6f8c15536c916da40f to your computer and use it in GitHub Desktop.
ajaxComplete
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment