Skip to content
Create a gist now

Instantly share code, notes, and snippets.

$.get('/path/to/url', function (data) {
if( !data || data === ""){
// error
var json;
try {
json = jQuery.parseJSON(data);
} catch (e) {
// error
// use json here
}, "text");

Neat script. This saved my bacon recently so thanks a lot. One question: why does the dataType need to be set to 'text'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.