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 should be equal to jsonpURL in your onRequest function.