views:

43

answers:

1

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?

+1  A: 

jQuery.getJSON doesn't allow you to define an error callback function.

You'll need to use jQuery.ajax instead, setting the dataType to json and set the remaining configuration variables as getJSON defines by default.

Seb
Yeah, I thought this was the only way. Ill just get the result, check if it's format is the correct and proceed. Thanks
Bathan