I have a ajax
function which will call a function if its error
and this error will call a function which displays the error message. here is the code
function Update_uam() {
$.ajax({
type: "POST",
url: "IROA_StoredProcedures.asmx/update_uam1",
data: "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
console.log(tbody);
},
error: errorHandler
});
}
function errorHandler(XMLHttpRequest) {
console.log(errorHandler.caller.caller);
console.log(XMLHttpRequest);
}
I tried several ways but seems to failed. What I want to do is also displays which function the error comes from for easy debugging.
I think you should use :
function Update_uam() {
$.ajax({
type: "POST",
url: "IROA_StoredProcedures.asmx/update_uam1",
data: "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
console.log(tbody);
},
error: function (jqXHR, exception) {
var msg = '';
if (jqXHR.status === 0) {
msg = 'Not connect.
Verify Network.';
} else if (jqXHR.status == 404) {
msg = 'Requested page not found. [404]';
} else if (jqXHR.status == 500) {
msg = 'Internal Server Error [500].';
}
$('#post').html(msg);
},
});