先附上代码:
插件代码片段:
$.getJSON("http://crazywe.sinaapp.com/orderprice?callback=?", function(data){
alert("test");
});
manifest.json 片段:
"content_scripts": [
{
"css": ["css/iwlw.css"],
"matches": ["http://*/*","https://*/*"],
"js": ["js/jquery-2.1.1.min.js","js/anpai.js"]
}
],
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
]
后台java代码:
resp.setContentType("text/javascript");
resp.setHeader("Access-Control-Allow-Origin", "*");
PrintWriter out = resp.getWriter();
out.println(req.getParameter("callback") + "(" + resultJSON.toString() + ");");
//out.println("orderpriceforanpai(" + resultJSON.toString() + ")");
out.flush();
out.close();
现在本地调试没有问题,但是把jsonp的代码封装到chrome插件之后报错如下:is not defined
是在解决不了,求大神点解!!!
感觉chrome插件完全可以跨域的情况下,完全用不上jsonp