Hi All, I have a jquery code in which I am using get() and calling some remote url/file. Now I want to know what the best way is to handle errors from this.
What I am doing is:
$(document).ready(function() {
$.ajaxSetup({
error: function(x, e) {
if (x.status == 0) {
alert(' Check Your Network.');
}
else if (x.status == 404) {
alert('Requested URL not found.');
} else if (x.status == 500) {
alert('Internel Server Error.');
} else {
alert('Unknow Error.\n' + x.responseText);
}
}
});
$.get("HTMLPage.htm", function(data) {
alert(data);
$('#mydiv').html(data);
});
});
This is working fine.But want to know is there any better way of doing this?