Javascript 错误;参数列表后未捕获的 SyntaxError: missing )

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30853666/
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-28 12:48:26  来源:igfitidea点击:

Javascript error; Uncaught SyntaxError: missing ) after argument list

javascriptjquerysyntax-error

提问by devin

I keep getting this error (Javascript error; Uncaught SyntaxError: missing ) after argument list)when trying to call a simple function. Everything works without calling it in a function but I need to do it multiple times.

尝试调用简单函数时,我不断收到此错误(Javascript 错误;未捕获的 SyntaxError: missing )在参数列表之后。一切正常,无需在函数中调用它,但我需要多次执行。

function myFunction(ip, port, div) {
    $.get('http://mcping.net/api/'+ ip + ":" + port, function(data){
        console.log(data.online);
        $(div).html(data.online);
    });
}
myFunction(162.223.8.210, 25567, #factionsOnline)

回答by adeneo

You're missing a parentheses because you didn't quote your strings

你缺少括号,因为你没有引用你的字符串

myFunction('162.223.8.210', '25567', '#factionsOnline');