'Jquery ajax not triggering when hitting 'warning'
I have an ajax call connected to a search that is calling an api that is spitting back jsonp results. This seems to be working fantastically except when they type something that is not there.
I get back a jsonp file in the console that is giving me a 'warning'
jQuery3600877660906184312_1652368192872({
"status": "warning",
"messages": {
"generalMessages": [{
"messageID": "1027",
"messageCriticality": "warning",
"messageText": "You provided an invalid field name."
}, {
"messageID": "1027",
"messageCriticality": "warning",
"messageText": "You provided an invalid field name."
}, {
"messageID": "1027",
"messageCriticality": "warning",
"messageText": "You provided an invalid field name."
}],
"recordMessages": []
},
"foundRows": 0,
"data": []
})
I have tried to account for this in my ajax call by adding a "fail" and a "warning" just hoping to catch it so I can handle it. Nothing seems to want to catch this though. Any ideas?
var encoded = $.toJSON(search)
$('#animalList').empty();
$.ajax({
url: 'url' + encoded,
dataType: 'jsonp',
success: function (data) {
// do stuff
},
warning: function (xhr, status, error) {
console.log('warning');
},
error: function (xhr, status, error) {
console.log('error');
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
