Skip to content

Commit

Permalink
no-callback fix for jsonp with server error (#1070)
Browse files Browse the repository at this point in the history
* no-callback fix for jsonp with server error

* jsonp unknown error message update
  • Loading branch information
strajuser authored and jgravois committed Mar 23, 2018
1 parent 77a10f8 commit a86cc7d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ export function jsonp (url, params, callback, context) {
script.type = 'text/javascript';
script.src = url + '?' + serialize(params);
script.id = callbackId;
script.onerror = function (error) {
if (error && window._EsriLeafletCallbacks[callbackId] !== true) {
// Can't get true error code: it can be 404, or 401, or 500
var err = {
error: {
code: 500,
message: 'An unknown error occurred'
}
};

callback.call(context, err);
window._EsriLeafletCallbacks[callbackId] = true;
}
};
DomUtil.addClass(script, 'esri-leaflet-jsonp');

callbacks++;
Expand Down

0 comments on commit a86cc7d

Please sign in to comment.