Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$.get('/path/to/url', function (data) {
if( !data || data === ""){
// error
return;
}
var json;
try {
json = jQuery.parseJSON(data);
} catch (e) {
// error
return;
}
// use json here
}, "text");
@rjbultitude

This comment has been minimized.

Show comment
Hide comment
@rjbultitude

rjbultitude Jul 2, 2014

Neat script. This saved my bacon recently so thanks a lot. One question: why does the dataType need to be set to '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