ajaxComplete问题

when below code executes it go to .ajaxComplete more than one time. Can i prevent this?

 $('.log').ajaxComplete(function(e, xhr, settings) {
      if (settings.url == 'ajax/test.html') {
        alert('hi');
      }
    });

Only solution what I found is, make settings.url = ''

 $('.log').ajaxComplete(function(e, xhr, settings) {
      if (settings.url == 'ajax/test.html') {

settings.url =  '';
        alert('hi');
      }
    });

But I do not find it appropriate

This should not happen - check out this jsfiddle:

This may be happening if:

  • There are other ajax requests - note that ajaxComplete gets called for any request (so e.g. some plugin on the page might be doing ajax in behind)
  • You called ajaxComplete multiple times

Otherwise, it should be called only once, as in the jsfiddle demo.