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

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -