missing ) after argument list 错误释疑
JavaScript 参数是string类型的时候前后要加“”,有些情况下一定要加转义符:例如下面情况:
这是 在servlet中的写法,因为用的ajax提交,所以使用PrintWriter对象输出内容
String ptostr = "aaaaaaaaaaaaa";
out.println("<span id='"+value+"' onclick='showContent(/""+ptostr+"/")'><img src='images/file3.gif' wdth='35' height='32'/> <font color='green'>" + value + "</font></span>");
写成下面情况会报:missing ) after argument list 错误
String ptostr = "aaaaaaaaaaaaa";
out.println("<span id='"+value+"' onclick='showContent("+ptostr+")'><img src='images/file3.gif' wdth='35' height='32'/> <font color='green'>" + value + "</font></span>");
上面这种写法,当初 怎么都没有查出错了,使用alert打印的时候也没有什么错误,但是一输出到页面绝对就报missing ) after argument list 错误
-
顶
本文探讨了JavaScript中一种常见的异常——missing)afterargumentlist,并通过具体代码示例展示了如何避免这一错误的发生。该错误通常出现在字符串拼接时未正确处理参数列表。
7986

被折叠的 条评论
为什么被折叠?



