I\'m trying to intercept all AJAX calls in order to check if that AJAX response contains specific error code that I send as JSON from my PHP script (codes: ACCESS_DENIED, SY
The raw javacript code to intercept ajax calls:
(function(send) {
XMLHttpRequest.prototype.send = function(body) {
var info="send data\r\n"+body;
alert(info);
send.call(this, body);
};
})(XMLHttpRequest.prototype.send);
The jQuery code to intercept ajax:
$.ajaxSetup({
beforeSend: function (xhr,settings) {
alert(settings.data);
alert(settings.url);
}
});
Reference: http://myprogrammingnotes.com/intercept-ajax-calls-jquery.html