[AJAX] xmlhttp.status geeft steeds 0

Gestart doorAlemaalte0 reacties34 weergaven

1 berichten · pagina 1 van 1

Alemaalte

Lid · Topicstarter

Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,

Dit is mijn code:

<html>
    <head>
        <link href="style.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            function screen()
            {
            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("frame").innerHTML=xmlhttp.responseText;
                }
              }
            xmlhttp.open("GET","screen.php",true);
            xmlhttp.send();
            }
            function login_check(id)
                {
                    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()
                      {
                      alert(xmlhttp.readyState);
                      alert(xmlhttp.status);
                        if (xmlhttp.readyState==4 && xmlhttp.status==200)
                            {
                                alert("test");
                                alert(xmlhttp.responseText);
                            }
                        if (xmlhttp.readyState==4 && xmlhttp.status==404)
                            {
                                alert("test");
                                alert(xmlhttp.responseText);
                            }
                      }
                    xmlhttp.open("GET","login.html",true);
                    xmlhttp.send();
                }
            function changeColor(id, color) {
                element = document.getElementById(id);
                event.cancelBubble = true;
                oldColor = element.currentStyle.background;
                element.style.background = color;
            }
            function login(id) {
                element = document.getElementById(id);
                event.cancelBubble = true;
                if(element.style.height != "50px")
                    {
                        element.style.height = "50px";
                        element.innerHTML = id+"</br><input type="password" name="pass" />";
                    }
                else
                    {
                        login_check("test");
                    }
            }
            function unshow(id) {
                element = document.getElementById(id);
                event.cancelBubble = true;
                element.style.height = "30px";
                element.innerHTML = id;    
            }
        </script>
    </head>
    <body>
        <div id="frame">
            <div id="login">
                <div class="user" id="Stewie" ondblclick="unshow(this.id);" onClick="login(this.id);" onMouseOver="changeColor(this.id, #537FA6);" onMouseOut="changeColor(this.id, #114261);">
                    Stewie
                </div>
                <div class="user" id="Brian" ondblclick="unshow(this.id);" onClick="login(this.id);" onMouseOver="changeColor(this.id, #537FA6);" onMouseOut="changeColor(this.id, #114261);">
                    Brian
                </div>
                <div class="user" id="Meg" ondblclick="unshow(this.id);" onClick="login(this.id);" onMouseOver="changeColor(this.id, #537FA6);" onMouseOut="changeColor(this.id, #114261);">
                    Meg
                </div>
                <div class="user" id="Peter" ondblclick="unshow(this.id);" onClick="login(this.id);" onMouseOver="changeColor(this.id, #537FA6);" onMouseOut="changeColor(this.id, #114261);">
                    Peter
                </div>
            </div>
        </div>
    </body>
</html>


De readystate veranderd 4 keer maar de status blijft 0.
Weet iemand hoe dit komt?

Mvg,
alemaalte
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren