From a86cc7dd09b07d0e722a4023922d43e85205b341 Mon Sep 17 00:00:00 2001 From: Dmitri Date: Fri, 23 Mar 2018 19:03:22 +0300 Subject: [PATCH] no-callback fix for jsonp with server error (#1070) * no-callback fix for jsonp with server error * jsonp unknown error message update --- src/Request.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Request.js b/src/Request.js index b5aaad262..38056cb22 100644 --- a/src/Request.js +++ b/src/Request.js @@ -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++;