JQuery.getJSON (). Error () fails when error 404

This is a brief overview of my code:

$.getJSON(json_url, function(data) { // application logic }).error(function() { console.log("error"); }); 

The problem is that when the server returns a 404 error, it does not seem to be processed, because there is no console.log() error, but there is a GET request error with the 404 (Not Found) code displayed in the console.

I am using jQuery 1.9.0.

Is there some simple mistake I am making?

+4
source share
1 answer

Due to the nature of JSONP requests, an error callback is not called.

From docs :

When data is retrieved from remote servers (which is only possible using script or jsonp data types), callbacks and global events will never be fired.

+3
source

All Articles