I\'ve got an AJAX request that expects JSON in response.
But there\'s a possibility that what gets returns may not be JSON, but rather an HTML error page (unfortunat
jQuery parseJSON function can be used for this. It will throw an exception then you can catch it go ahead.
data = '{}'; try { json = $.parseJSON(data); } catch (e) { // not json }