Currently, we are using ajaxComplete listener which is calling specific function which I mentioned after every ajax call happened.
$(document).ajaxComplete(function () {
someFunction();
})
There is one scenario that after specific ajax call,I want to do something instead of calling someFunction().
Is there a way to exclude a specifc ajax call from ajaxComplete?
Currently, we are using ajaxComplete listener which is calling specific function which I mentioned after every ajax call happened.
$(document).ajaxComplete(function () {
someFunction();
})
There is one scenario that after specific ajax call,I want to do something instead of calling someFunction().
Is there a way to exclude a specifc ajax call from ajaxComplete?
Share Improve this question edited Apr 1, 2014 at 19:18 gen_Eric 227k42 gold badges303 silver badges342 bronze badges asked Apr 1, 2014 at 19:17 chanduchandu 2331 gold badge6 silver badges13 bronze badges2 Answers
Reset to default 7Here is small example how you can use the settings argument in the $.ajaxComplete
$.ajax({
type:"GET",
url:"http://google."
});
$.ajax({
type:"GET",
url:"https://stackoverflow."
});
$(document).ajaxComplete(function(event,xhr,settings){
console.log("URL",settings.url);
if(settings.url === "https://stackoverflow.")
{
$(".loadedPage").html("Stackoverflow loaded");
}
else if(settings.url === "http://google.")
{
$(".loadedPage").html("Google Loaded");
}
});
Hope this helps!!
See the jQuery docs for it
You are supplied with the event object, the XMLHttpRequest object and the settings object for each Ajax call. Use this to differentiate between your calls.