为什么我会收到“Uncaught SyntaxError: Unexpected token ILLEGAL”错误提示?

4

I have this simple script:

    ids="22656"
    url = "http://api.stackoverflow.com/1.0/users/"+ids+"/timeline";
    console.log( url );
    xmlhttp = new XMLHttpRequest();
    xmlhttp.open(“GET”, url ,true);
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) {
            console.log( xmlhttp.responseText );
        }
        xmlhttp.send( null );
    };    

但我不太明白为什么会得到以下信息:
Uncaught SyntaxError: Unexpected token ILLEGAL

有人可以解释一下这个吗?

将XMLHttpRequest发送到不同于您自己的域名...无论如何都不会起作用。您在哪里看到这个错误,什么时候看到的? - Pointy
1个回答

10

对于 GET 周围的引号不正确。您必须使用标准的单引号或双引号来表示字符串。


哇!太棒了!!!我从没意识到我有不同的引号。我可能是从一个网页上复制的,可能是 HTML 渲染改变了它们。现在我得到了 Origin null is not allowed by Access-Control-Allow-Origin ,但我猜这就是 @Pointy 所提到的问题。 - OscarRyz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接