fbpx

“What’s the point” you ask?

The point is that you can’t just bind willy-nilly to ajaxComplete on a page where there are multiple elements using ajax. You have two options: either filter the results like so:

jQuery( document ).ajaxComplete(function( event, xhr, settings ) {
  if ( settings.url === "ajax/test.html" ) {
    jQuery( ".log" ).text( "Triggered ajaxComplete handler. The result is " +
      xhr.responseText );
  }
});

Or, as is sometimes the case, you want to reload or redirect the entire page on completion of a particular action, usually triggered by a click. You can use the method above to do it, but I find the .click method more readable if I wander back six months later and have to try to figure out what I was doing, which is often the case.

jQuery(document).ready(function() {
  jQuery('.mss-item-cell').click( function(){ 
   jQuery ( document ).ajaxComplete( function() {
      // do your stuff
	 // i.e. to reload the page after the action is complete go:
	 // location.reload(); 
     });
   });
});