I m using JSONP in a google chrome extension. In order to make it work, i had to add
chrome.extension.onRequest.addListener(onRequest);
然后提出这样的请求:
var jsonpURL;
$(document).ready(function(){
/* i make the "someurl" here from a div s content */
jsonpURL="someurl";
chrome.extension.sendRequest({action: getJSON ,url:jsonpURL});
});
在收听器里我喜欢在页面上隐藏一些 div 。
function onRequest(request, sender, callback) {
if (request.action == getJSON ) {
$.getJSON(request.url, function(data){
// HIDE SOME DIV
});
}
}
问题:
how can i reach the original page s content in the onRequest
function? or if i cant at all, how can i hide some divs depending on the result of request?
i tried jquery selectors and figured out that i reach the bg.htlm, and not the original page.