I\'m making some GET requests to an App Engine app, testing in Chrome. Whilst I can see in javascript console that some calls result in a 500 server error, I can\'t seem to
Solved the problem by upgrading jQuery from 1.9.1 to 2.1.1 — now it started calling .error()
right on the server response (before it would ignore the 500 response and wait until timeout is over).
Limitation: jQuery 2.1.1 does not support IE8 and below (as IMO shouldn't you)
I had a similar problem, I was using jquery's promise functions of .done, .fail, .always, and if I encountered a 500 internal server error then it would not fire any of the functions (done, fail, always, error). very weird.
in the end I added a timeout into the .ajax options, when it hits the timeout it throws an error and also runs the .fail method.
searchify.myAjaxSearchTerms = $.ajax({
'url': url,
type: "GET",
'dataType': 'jsonp',
'jsonp': 'json.wrf',
'jsonpCallback': searchify.cbFunc,
timeout: 4000, //needed for 500 errors - will go to fail block on timeout
beforeSend: searchify.beforeSendAutocomplete
});
searchify.myAjaxSearchTerms.fail(function(XHR, status, error){
searchify.clearForm();
searchify.renderWarningForNoQuery('<div class="notify-bubble"><span class="icon" data-icon="8" aria-hidden="true"></span><span>Sorry. We had a problem performing that search...<br/>Please try again<br/>Enter a <strong>product name</strong>, <strong>catalogue number</strong> or <strong>keyword</strong></span></div>');
});
It doesn't look like you're using jQuery's document.ready
binding correctly. The $().ready(...)
version is more-or-less deprecated. Try one of these instead:
$(document).ready(function() {
$.ajaxSetup({
error: function(x, e) {
if (x.status == 500) {
alert('Internel Server Error.');
}
}
});
});
or the shorthand:
$(function() {
$.ajaxSetup({
error: function(x, e) {
if (x.status == 500) {
alert('Internel Server Error.');
}
}
});
});