I have the following code
jQuery.getJSON(encodeURI(strUrl), {address:address,state:state, zip:zip},function(data){
alert('HELLO World!');
});
If for some reason the strUrl returns a string that’s not in JSON format the callback function never gets called. Is there a way to know if the response is in json format or if something went wrong in the post?
jQuery.getJSONdoesn’t allow you to define an error callback function.You’ll need to use
jQuery.ajaxinstead, setting thedataTypetojsonand set the remaining configuration variables as getJSON defines by default.