开发者

$(document).ready(function not loading unless refreshed

开发者 https://www.devze.com 2023-03-10 13:53 出处:网络
I am usingjQuery and the $(document).ready event. when i load in IE8 i get an error \"Object doesn\'t support this property or method\". When i refresh it works fine. Here is my code:

I am using jQuery and the $(document).ready event. when i load in IE8 i get an error "Object doesn't support this property or method". When i refresh it works fine. Here is my code:

    <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-ww开发者_高级运维w-form-urlencoded");
       xmlhttp.send();
   });
  </script>

I have the following in my head tag:

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

Any help would be appreciated i have tried $(window).load and others.


Use the jQuery library when you include it, as you are using only the $(document).ready() function.

Try this code (it accomplishes the exact same thing as yours):

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

This line also might be problematic:

<script language="text/javascript">

You are specifying the type, not the language. Try this one instead:

<script type="text/javascript">
0

精彩评论

暂无评论...
验证码 换一张
取 消