I need to call execute ajax call from withing ajaxComplete function. How do I do this without getting stuck in endless loop of ajax calls? Can I unbind ajaxComplete, run ajax call, and then re-bind it? If so, how?
A:
How about:
function onComplete(event, XMLHttpRequest, ajaxOptions)
{
// Your second AJAX call
$.ajax({
url: "anotherPlace.html",
cache: false
});
}
// Your first ajax call
$.ajax({
url: "test.html",
cache: false,
complete: onSuccess
});
Januz
2010-01-13 19:42:18
It has to be from global ajaxComplete(). For now I am just looking at settings.url and if it is the second call just return.
epitka
2010-01-13 19:44:13
Well, in that case yeah, you can bind() and unbind() ajax events:http://docs.jquery.com/Ajax_EventsThough the way you're doing it now will probably run faster.
Januz
2010-01-13 22:50:12
A:
Can't you just use a global variable. First time run check if variable is set, if not give it a value. Second time you run it, check again and variable is probably set.
jerone
2010-01-13 19:49:09