Closed gxxcastillo closed 11 years ago
The JSON.parse(jqXhr.responseText || '{}') line assumes responseText will be a json object. However, there is a chance it will not be (such as in some 404 responses).
JSON.parse(jqXhr.responseText || '{}')
Backbone.Siren.ajax(rootUrl, options) .done(function (entity) { var bbSiren = Backbone.Siren.parse(entity); deferred.resolve(bbSiren); handleRootRequestSuccess(bbSiren, chain, chainedDeferred, options); }) .fail(function (jqXhr) { var entity = JSON.parse(jqXhr.responseText || '{}') , bbSiren = Backbone.Siren.parse(entity); deferred.reject(bbSiren, jqXhr); chainedDeferred.reject(bbSiren, jqXhr); });
The
JSON.parse(jqXhr.responseText || '{}')
line assumes responseText will be a json object. However, there is a chance it will not be (such as in some 404 responses).