简体   繁体   English

xmlhttprequest在chrome扩展中不起作用

[英]xmlhttprequest is not working in chrome extension

I have to read xml file placed on ftp server. 我必须阅读放置在ftp服务器上的xml文件。 But when i try to open connection and on php run simple mysql query for checking purpose its not working. 但是,当我尝试打开连接并在php上运行用于检查目的的简单mysql查询时,它不起作用。 Can anybody help please. 有人可以帮忙吗? The code in content script is given. 给出了内容脚本中的代码。

 if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp=new XMLHttpRequest();
 }

 else
 {// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 xmlhttp.onreadystatechange=function()
 {
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert("connection to ftp server is established successfully");
}
}

var str="name";
xmlhttp.open("GET","http://my severurl/foldername/file.php?     
q="+str,true,"username","password");
xmlhttp.send();
alert("worked");    

Have you checked that you added the permission in the manifest.json: 您是否已检查是否在manifest.json中添加了权限:

  "permissions": [
    "http://myseverurl/foldername/file.php",
    "tabs",
    "etc..",]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM