Is it possible to block an ajax call by its url from another script/js file? I want something like that..
if(ajax_url == 'if_URL_match_then_block_this_ajax_call'){
//block lower ajax call
}
$.ajax({
type: "GET",
url: 'if_URL_match_then_block_this_ajax_call',
data: {},
success: function(e) {
//some event after success...
}
});
2
Answers
At last I found an answer. I can block a specific url when ajax call start sending request.
Ref: https://api.jquery.com/ajaxSend/
It’s a little hard to tell by the code snippet, but if this code is inside a function you could exit the function early if you detected the URL you didn’t want to send a request for.