Empty XmlHttp responsetext (only Google Chrome)

后端 未结 1 1016
南方客
南方客 2021-01-24 08:50

I have a problem with my chat script in Google Chrome. Sometimes the responsetext is empty until you reload the page, but sometimes it\'s working well. It opens a xmlhttp connec

1条回答
  •  无人及你
    2021-01-24 09:17

    try this out

    var xmlHttp;
    xmlHttp=new XMLHttpRequest();
    var url = "text.php";
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var msg = xmlHttp.responseText;
            alert(msg);
        }
    }
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    

    0 讨论(0)
提交回复
热议问题