sica07
sica07

Reputation: 4956

Code inside .ajaxStop repeats continuosly

What I want is to run a function only when all the content of a specific div is loaded and all the ajax requests related to that div are completed. So I have this piece of code:

$('#calendar-cont').ajaxStop(function() {
       getEventsData();// a function that contains some ajax requests

});

The problem is that the getEventsData() contains some other ajax requests and, for a reason that I don't understand (but I think is related to the ajax requests inside the getEventsData()) this function is run over and over again. What am I missing?

Upvotes: 0

Views: 236

Answers (1)

stewe
stewe

Reputation: 42644

ajaxStop is not specific to a certain element, so ajaxStop will be called after the ajax request inside getEventsData() has finished, so you have an infinite loop.

Upvotes: 1

Related Questions