I have this jsonp function:
function jsonp(url, callback) {
var script = document.createElement("script");
script.setAttribute("type","text/javascript");
script.setAttribute("onerror","javascript:DisplayPopUp('','staleExceptionRefresh')");
script.setAttribute("src", url + questionMark + "accept=jsonp&callback="+callback + "&cachebuster="+new Date().getTime());
document.getElementsByTagName("head")[0].appendChild(script);
}
I catch the success event like this:
function someCallbackFunction(data1, data2) {}
but the problem is that if I get 404 or 409 or some other server errors I don't know how to catch them (they do not appear on someCallbackFunction
).
I can set an onerror
attribute to display something but how do I catch the server's response.
this is an example for a server response that I am not able to catch with my regular callback function:
DeleteWebsiteAjaxCall({"action":"", "type":"", "callerId":""}, {errorDescription: "important description I want to display","success":false,"payload":null});
How do I catch these errors (stale exceptions?!) on a function?