I have the following code and I get JSON from the site using JSONP. I want to process an error code, for example, 404 bad request. The following does not work for me.
$.getJSON('https://xyz.com/search?jsonp-callback=?', function(data) { alert("success"); }) .success(function() { alert("success 2"); }) .error(function() { alert("error occurred "); }) .complete(function() { alert("Done"); });
Successful and complete methods work, but the error method does not work.
source share