Skip to content

Instantly share code, notes, and snippets.

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

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.