XMLHttpRequest仅适用于IE,不适用于其他浏览器

时间:2013-04-23 19:52:47

标签: internet-explorer google-chrome firefox post xmlhttprequest

我做过任何可能的搜索,仍然感到困惑。我试图将两个变量发送到某个php页面,但我的脚本仅适用于IE;其他浏览器不想发送请求。怎么了? 谢谢!

<script language="JavaScript" type="text/javascript">
function sendwnls(){

var hr = new XMLHttpRequest();

var url = "php_inc/rati.php";
var wn = "<?php echo $ln1 ?>";
var lns = "<?php echo $ln2 ?>";
var vars = "wn="+wn+"&ls="+ls;

hr.open("POST", url, true);

hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

 hr.onreadystatechange = function() {
 if(hr.readyState == 4 && hr.status == 200) {
  var return_data = hr.responseText;
  document.getElementById("status").innerHTML = return_data;
  }
  }

  hr.send(vars); // Actually execute the request
document.getElementById("status").innerHTML = "processing...";
}

0 个答案:

没有答案