views:

246

answers:

2

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
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
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
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