Javascript XMLHttpRequest不适用于chrome版本23&;在上面
我已经创建了chrome扩展并将crx文件添加到chrome扩展部分。这个.crx文件是使用javascript和manifest.json文件创建的。从java脚本开始,我每隔10秒向我的java servlet发送一次XMLHttpRequest。我已经在chrome版本18和19上对此进行了测试,它工作正常,但当我试图在chrome版本23中添加.crx文件时,XMLHttpRequest不工作。 javaScript代码是:-Javascript XMLHttpRequest不适用于chrome版本23&;在上面,javascript,gwt,google-chrome-extension,Javascript,Gwt,Google Chrome Extension,我已经创建了chrome扩展并将crx文件添加到chrome扩展部分。这个.crx文件是使用javascript和manifest.json文件创建的。从java脚本开始,我每隔10秒向我的java servlet发送一次XMLHttpRequest。我已经在chrome版本18和19上对此进行了测试,它工作正常,但当我试图在chrome版本23中添加.crx文件时,XMLHttpRequest不工作。 javaScript代码是:- try{ var xmlhttp; if
try{
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200){
/* document.getElementById("myDiv").innerHTML=xmlhttp.responseText;*/
// alert(xmlhttp.responseText);
if(xmlhttp.responseText!="?"){
chrome.browserAction.setBadgeText({text : xmlhttp.responseText});
chrome.browserAction.setIcon({path:"images/IconGreen.png"});
chrome.browserAction.setBadgeBackgroundColor({color : [ 208, 0, 24, 255 ]});
}
else{
chrome.browserAction.setBadgeText({text :"?"});
chrome.browserAction.setIcon({path:"images/IconGrey.png"});
chrome.browserAction.setBadgeBackgroundColor( {color:[190, 190, 190, 230]});
}
}
};
xmlhttp.open("GET"," http://127.0.0.1:8888 /engile/realTimeUpdateCountServlet",true);
xmlhttp.send();
} catch (err) {
alert(err.message);
}
&manifest.json是
{
"name": "A Chrome Extension",
"version": "4.4.0",
"background": { "scripts": ["background.js"] },
"permissions": [
"tabs",
"webNavigation",
"http://*/*",
"chrome.action"
],
"web_accessible_resources": [
"278CB17EDF811DAFF4CBD7790CBE8C06.cache.html"
],
"browser_action": {
"name": "Make this page red",
"default_icon": "images/IconGrey.png"
},
"manifest_version": 2
}
请给我任何建议。您代码中的问题
,没有名为名称的参数,它必须是“浏览器操作”:{“名称”:“使此页面变为红色”
“默认标题”
没有名为“权限”:[“选项卡”、“网络导航”、“http://*/*”、“chrome.action”],
从添加相关权限chrome.action的权限。