UPDATE
Here Ajax receives some responseimage from the server
success: function(responseimage)
{
.....
}
This gets object and puts it into result variable.
result = jQuery.parseJSON(responseimage);
response image is always positive. It has always something inside
Problem is that sometimes in responseimage there is no JSON object.
So how can I check it after getting result frmo server is there any object or not ?
if( result = jQuery.parseJSON(responseimage)) crashes script
if( typeof jQuery.parseJSON(responseimage)!='undefined') crashes script
Any other ways to check ?
In lieu of writing a more intelligent
tryParseJSONfunction (one may already exist, I’m not sure), I would simply wrap the parse call in a try-catch block: