0

我试图每隔“n”个时间段执行一个javascript函数,该函数将调用一个php文件,该文件将执行一种代码,但不幸的是它不起作用,这里是代码

<p id="code"></p>

    <script>
    var myVar=setInterval(function(){showUser()},1000);



    function showUser() {
        var xmlhttp = null;
        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('txtHint').innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open('GET', 'getuser.php');
        xmlhttp.send();
    document.getElementById("code").innerHTML=t;

    }
    </script>
4

1 回答 1

0
//edit this

document.getElementById('txtHint').innerHTML = xmlhttp.responseText;

//to

document.getElementById("code").innerHTML = xmlhttp.responseText;


//and delete

document.getElementById("code").innerHTML=t;
于 2013-08-15T20:04:49.123 回答