There are several different options for getting the actual answer: whether it was processed by JSON or the error created by the browser / server that the getJSON method tried to parse, but could not.
Note: when using the ".always" method, the parameters change depending on failure or success.
$.getJSON(getData.php, function(data,textStatus,jqXHR) { console.log(jqXHR.responseText); //As of 1.5 we have these methods: }).always( function(jqXHR, textStatus, errorThrown) { //on failure console.log(jqXHR.responseText); }).always( function(data, textStatus, jqXHR) { //on success console.log(jqXHR.responseText); }).fail( function(jqXHR, textStatus, errorThrown) { console.log(jqXHR.responseText); //As of 1.8 we have this method also: }).then( function(data, textStatus, jqXHR) { console.log(jqXHR.responseText);}, function(jqXHR, textStatus, errorThrown) { console.log(jqXHR.responseText); });
If you want more information:
http://api.jquery.com/jQuery.ajax/#jqXHR or
http://api.jquery.com/category/deferred-object/
toddles_fp
source share