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?
Here is small example how you can use the settings argument in the $.ajaxComplete
$.ajax({
type:"GET",
url:"http://google.com"
});
$.ajax({
type:"GET",
url:"https://stackoverflow.com"
});
$(document).ajaxComplete(function(event,xhr,settings){
console.log("URL",settings.url);
if(settings.url === "https://stackoverflow.com")
{
$(".loadedPage").html("Stackoverflow loaded");
}
else if(settings.url === "http://google.com")
{
$(".loadedPage").html("Google Loaded");
}
});
Hope this helps!!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments