Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript $。发布未在ie中工作。请提供其他方式帮助?_Javascript_Jquery_Ajax_Xmlhttprequest - Fatal编程技术网

Javascript $。发布未在ie中工作。请提供其他方式帮助?

Javascript $。发布未在ie中工作。请提供其他方式帮助?,javascript,jquery,ajax,xmlhttprequest,Javascript,Jquery,Ajax,Xmlhttprequest,我使用$.post在我的网页中发送和接收响应。但它在Internet Explorer中不起作用。我使用了另一种Ajax方式。我必须创建xmlhttprequest对象 我的代码是 var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } e

我使用$.post在我的网页中发送和接收响应。但它在Internet Explorer中不起作用。我使用了另一种Ajax方式。我必须创建xmlhttprequest对象

我的代码是

     var xmlhttp;
     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)
       {
       document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
        }
      }
     xmlhttp.open("POST","demo_post2.asp",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
      xmlhttp.send("fname=Henry&lname=Ford");
这适用于除ie-10之外的所有浏览器。为了支持ie-10,我编写了如下代码

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

它不是与mozila、safari合作,而是与ie-10合作。我还没有和ie-7核实过。这是一场冲突。请为我提供任何帮助……….

尝试使用第一种方法,并封装您的发送功能,如下所示

setTimeout(function () {
xmlhttp.send();
}, 0);

显示“
$.post
在Internet Explorer中不起作用”的代码可能是更好的方法…jQuery.post或jQuery.ajax有什么问题?