我正在尝试在Google chrome扩展程序中使用XMLHttpRequest,但结果并不令人满意,它不起作用
{
"manifest_version": 2,
"name": "TESTE",
"description": "Reader",
"version": "10.1.11",
"minimum_chrome_version": "40",
"content_scripts" : [
{
"matches" : [
"http://*/",
"https://*/"
],
"js" : ["meu.js"],
"run_at" : "document_end",
"all_frames" : true
}],
"permissions": [
"tabs",
"https://*/",
"http://*/"
]
}
function fdata()
{
http = false;
/* For Firefox*/
if (window.XMLHttpRequest) {
http = new XMLHttpRequest();
} else /*For IE*/
if (window.ActiveXObject) {
try {
/*For some versions of IE*/
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
/*For some other versions of IE*/
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = "http://191.xxx.xxx.xxx/02082018001/add_m.php";
var params = "l_data=teste";
http.open('POST', url, true);
http.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.send(params);
}
我正在尝试在Google chrome扩展程序中使用XMLHttpRequest,但结果不令人满意,它不起作用