Skip to content

Commit 94b3c7d

Browse files
修复 jsonp 功能失效 review by luox
1 parent 655c18f commit 94b3c7d

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/common/util/FetchRequest.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ export var RequestJSONPPromise = {
3131
uid = me.getUid(),
3232
url = config.url,
3333
splitQuestUrl = [];
34-
var p = new Promise(function (resolve) {
35-
me.supermap_callbacks[uid] = function (response) {
36-
delete me.supermap_callbacks[uid];
37-
resolve(response);
38-
};
39-
});
4034

4135
// me.addQueryStrings({
4236
// callback: "RequestJSONPPromise.supermap_callbacks[" + uid + "]"
@@ -94,12 +88,11 @@ export var RequestJSONPPromise = {
9488
}
9589
}
9690
splitQuestUrl.push(sectionURL);
97-
me.send(
91+
return me.send(
9892
splitQuestUrl,
99-
'RequestJSONPPromise.supermap_callbacks[' + uid + ']',
93+
'SuperMapJSONPCallbacks_' + uid,
10094
config && config.proxy
10195
);
102-
return p;
10396
},
10497

10598
getUid: function () {
@@ -126,9 +119,11 @@ export var RequestJSONPPromise = {
126119
url = decodeURIComponent(url);
127120
url = proxy + encodeURIComponent(url);
128121
}
129-
fetchJsonp(url, {
122+
return fetchJsonp(url, {
130123
jsonpCallbackFunction: callback,
131124
timeout: 30000
125+
}).then((result) => {
126+
return result.json();
132127
});
133128
}
134129
}

test/common/util/FetchRequestSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('FetchRequest', () => {
88
fetch = jasmine.createSpy('fetch').and.resolveTo({ success: 'ok' });
99
setFetch(fetch);
1010
});
11-
xit('RequestJSONPPromise', () => {
11+
it('RequestJSONPPromise', () => {
1212
var url = 'http://test.supermap.io/examples/leaflet/editor.html#addressMatchService';
1313
var params;
1414
var options;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy