Skip to content

Commit

Permalink
create script tag after JSONP callback function is defined (Esri#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgravois committed Apr 26, 2016
1 parent e47fe48 commit 3d6f8a2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,8 @@ export function request (url, params, callback, context) {
export function jsonp (url, params, callback, context) {
window._EsriLeafletCallbacks = window._EsriLeafletCallbacks || {};
var callbackId = 'c' + callbacks;

params.callback = 'window._EsriLeafletCallbacks.' + callbackId;

var script = L.DomUtil.create('script', null, document.body);
script.type = 'text/javascript';
script.src = url + '?' + serialize(params);
script.id = callbackId;

window._EsriLeafletCallbacks[callbackId] = function (response) {
if (window._EsriLeafletCallbacks[callbackId] !== true) {
var error;
Expand All @@ -192,6 +186,11 @@ export function jsonp (url, params, callback, context) {
}
};

var script = L.DomUtil.create('script', null, document.body);
script.type = 'text/javascript';
script.src = url + '?' + serialize(params);
script.id = callbackId;

callbacks++;

return {
Expand Down

0 comments on commit 3d6f8a2

Please sign in to comment.