javascript 为什么我得到:Uncaught SyntaxError: Unexpected token ILLEGAL here
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5171489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 16:14:31 来源:igfitidea点击:
Why am I getting : Uncaught SyntaxError: Unexpected token ILLEGAL here
提问by OscarRyz
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 );
};
But I don't quite understand why I'm getting:
但我不太明白为什么我得到:
Uncaught SyntaxError: Unexpected token ILLEGAL
Can someone shed some light on this?
有人可以对此有所了解吗?
回答by jordancpaul
The quotes around GET are not proper. You must use standard single or double quotes for strings.
GET 周围的引号不正确。您必须对字符串使用标准的单引号或双引号。

