Skip to content

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.

Copy link

commented 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'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.