I'm using JSONP in a google chrome extension. In order to make it work, i had to add
chrome.extension.onRequest.addListener(onRequest);
and then make the request like this:
var jsonpURL;
$(document).ready(function(){
/* i make the "someurl" here from a div's content */
jsonpURL="someurl";
chrome.extension.sendRequest({action:'getJSON',url:jsonpURL});
});
and the problem is, i cant acces the jsonpURL
variable in the request:
function onRequest(request, sender, callback) {
alert(jsonpURL);
}
Undefinied.
seems like the jsonpURL
variable has no value at the request despite i start it only after i gave value to the jsonpURL
variable in the ready function.
request.url应该与onRequest函数中的jsonpURL相等。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.