我正在使用 AJAX 系统提交表单,但我什至无法加载我的 JavaScript,Firebug 报告如下。
missing ) after argument list
else if( httpRequest.responseText == 'already logged in' )\n
我在互联网上四处寻找,但我发现的只是引用中的错误。 ( Example , Another Example )。我没有任何错误引用,所以我真的不明白发生了什么。下面是我的更多代码。
(删除了一些不相关的函数调用以删除加载消息。)
if(httpRequest.responseText != "failure") // Works fine!
{
document.getElementById("result").innerHTML = "[Success message]";
setTimeout("2000", function(){ window.location.assign("[link to page]");
}
else if(httpRequest.responseText == 'already logged in') // Similar to above, but fails
{
document.getElementById("result").innerHTML = "[error message]";
}
else
{
document.getElementById("result").innerHTML = "[error message]";
}
有人知道为什么会出现这个错误吗?
(对于更多成员,概述导致此错误的原因可能会有用,这将允许此页面与其他代码一起工作)
最佳答案
这条线
setTimeout("2000", function(){ window.location.assign("[link to page]");
错过了 })
导致下一行失败(无论如何整个语法都是错误的:)
应该是
setTimeout (function(){ window.location.assign("[link to page]") } , 2000 );
setTimeout
接受一个函数作为第一个参数,一个整数作为第二个参数。
关于javascript - 为什么我会收到 "missing ) after argument list"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6403938/