1

我正在使用 jQuery 和 $(document).ready 事件。当我在 IE8 中加载时,我收到一个错误“对象不支持此属性或方法”。当我刷新它工作正常。这是我的代码:

    <script language="text/javascript">
    $(document).ready(function ()
    {
        var xmlhttp;
        xmlhttp=new XMLHttpRequest();
        xmlhttp.onreadystatechange=function()
       {
     if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
       document.getElementById("loginbox").innerHTML=xmlhttp.responseText;
       }
    }
        xmlhttp.open("POST","loginform.php",true);
       xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
       xmlhttp.send();
   });
  </script>

我的头标签中有以下内容:

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js">

任何帮助将不胜感激我已经尝试过 $(window).load 和其他人。

4

1 回答 1

2

包含它时使用 jQuery 库,因为您只使用该$(document).ready()函数。

试试这个代码(它完成与你完全相同的事情):

$(document).ready(function() {
  $.post('loginform.php', $('#id_of_your_login_form').serialize(), function(response) {
    $('#loginbox').html(response);
  });
});

这条线也可能有问题:

<script language="text/javascript">

您指定的是type,而不是language。试试这个:

<script type="text/javascript">
于 2011-06-04T04:01:19.970 回答