javascript - AjaxComplete called to often -


i have code:

$( document ).ajaxcomplete(function( event, xhr, settings ) {     console.log('test'); }); 

i opened chrome network tab , can see 1 entry (status 200).

but console displays:

(28) test 

why executed often?

the ajaxcomplete triggers when ajax request completed, if it's successfull or not.
200 status code means request has gone right, but, can read in jquery docs callback fire every time ajax request has finished.

so, check url request redirecting , handle ones need.

anyway ( side note ) use built-in ajax callback function complete, this:

$.ajax({     url: url,     data: { data },     complete:function(){          console.log('test');      } }); 

Comments

Popular posts from this blog

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -