Fawn
Fawn

Reputation: 73

Does DOJO have a method of listening similar to .ajaxComplete() for when several AJAX calls are completed or successful?

I am looking for a DOJO function that runs changes when code is complete similar to this function below:

$(document).ajaxComplete(function() {
   // run changes here
});

I have tried:

dojo.addOnLoad(function(){
   // run changes here
});

However, I am losing my changes still when there is a DOJO AJAX call. I am not trying to make an AJAX call just to listen for a completed one.

Upvotes: 1

Views: 473

Answers (1)

D-S
D-S

Reputation: 61

Alternative to ajaxComplete in Dojo is listening to "done" event of dojo/request/notify module

notify("done", function(responseOrError){
    // Do something whether a request has succeeded or failed
    if(responseOrError instanceof Error){
        // Do something when a request has failed
    }else{
        // Do something when a request has succeeded
    }
});

See http://dojotoolkit.org/reference-guide/1.9/dojo/request/notify.html for more details.

Upvotes: 3

Related Questions