Home > DeveloperSection > Forums > Will jQuery ajaxStop() make recursive calls ? if so, how to stop it?
Ankita Pandey
Ankita Pandey

Total Post:183

Posted on    May-18-2013 1:36 AM


 1 Reply(s)
 3555  View(s)
Rate this:
Hi Everyone!

I'm showing Ajax login form for various user action in my portal, once successfully login I want to update some div's for that I'm using following code,


        var $html = $(html);
Will above code leads to any recursive Ajax calls ? currently its working as expected but I want to know it clearly.


I kept log at end of the ajaxStop then it printing log message recursively then it shows clearly that above code making recursive calls.


Total Post:604

Posted on    May-18-2013 8:34 AM

Hi Ankita!

I think this will cause recursion. After all the other AJAX calls complete, this handler will call. It will start a new AJAX call with $.get(), and when that completes it will trigger the handler, which will call $.get(), and so on.

To prevent this, you can do:

$.ajaxSetup( { global: false } );
to prevent global AJAX handlers from running. Or replace $.get() with the equivalent $.ajax() call, and use global: false in its options argument.

Don't want to miss updates? Please click the below button!

Follow MindStick