将xmlhttprequest.responseText分配给变量

时间:2017-10-05 10:10:49

标签: javascript xmlhttprequest referenceerror

下面的脚本返回一个ReferenceError:notifs未定义。

非常感谢。

var xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function()
{
    if (this.readyState == 4 && this.status == 200)
    {
        notifs = this.responseText;         
    }
};

xhttp.open("GET", "Space/notifs.php", true);
xhttp.send();
notif = notifs.split(",");

0 个答案:

没有答案