关于火狐运行var obj = eval('(' + data + ')');时 报SyntaxError: missing ] after element list错误,Chrome和IE正常

情形例如以下:

当使用ajax接收从后台传递过来的json数据时

$.ajax( {
type : "POST",
dataType : "json",
url : "RegisterAction.action",
data : params,
success : function(data) {
console.log(data);
var obj = eval('(' + data + ')');
console.info(obj);
},
error : function(data, status, e) {
alert("错误");
}
});

当设置dataType : "json", 程序会跳到error中

当去掉dataType : "json", 程序报SyntaxError: missing ] after element list错误

Struts配置为:

<struts>
<package name="build" extends="json-default">
<action name="RegisterAction" method="register" class="com.home.RegisterAction">
<result type="json"></result>
</action>
</package>
</struts>

Action为(部分代码):

public String register() {

	PrintWriter out;
try {
out = response.getWriter();
out.print("{msg:true,name:'" + name + "',sex:'" + sex + "'}");
out.close();
} catch (IOException e) {
e.printStackTrace();
} return null;
}

解决以上关于火狐报错问题的方法为:将dataType设置为html或text就可以

产生SyntaxError: missing ] after element list问题的解决办法并不一定都和本例中一样

也有可能因其它问题所产生,固本例不一定具有公共性,还需详细问题详细分析。

作者:itmyhome

出处:http://blog.csdn.net/itmyhome1990/article/details/41977941

SyntaxError: missing ] after element list 火狐问题的更多相关文章

  1. atitit.解决SyntaxError: missing ] after element list"不个object 挡成个str eval ....

    atitit.解决SyntaxError: missing ] after element list"不个object  挡成个str eval .... 1. 原因::: 不个object ...

  2. jQuery Ajax请求(关于火狐下SyntaxError: missing ] after element list ajax返回json,var json = eval("("+data+")"); 报错)

    $.ajax({    contentType: "application/x-www-form-urlencoded;charset=UTF-8" ,    type: &quo ...

  3. SyntaxError: missing ] after element list

    在前端页面js报错,找了很久没找到原因. 后来发现是后台向前端输出json字符串,而前端接收是html格式,需要将后台json字符串改成正常字符串就可以输出,或者通过ajax的方式接收json字符串.

  4. SyntaxError: missing ; before statement 错误的解决

    今天jsp页面中报错:SyntaxError: missing ; before statement 简单的理解是语法错误,F12调试之后发现原来是我定义的一个js中的全局变量的问题. <scr ...

  5. js错误 SyntaxError: missing : after property id

    在用jquery的post方法时 $.post('adminCheckTpmisPlans.do',{'test',str},function(f){ ... }) 报如下错误 SyntaxError ...

  6. python 错误之SyntaxError: Missing parentheses in call to 'print'

    SyntaxError: Missing parentheses in call to 'print' 由于python的版本差异,造成的错误. python2: print "hello ...

  7. SyntaxError: Missing parentheses in call to 'print'

    C:\Users\konglb>python Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (I ...

  8. SyntaxError: missing ) after argument list

    消息 语法错误: 参数列表后面缺少 ) 错误类型 SyntaxError. 什么地方出错了? 有一个函数在调用时出现错误.这可能是一个错误,丢失运算符或者转义字符等. 示例 因为没有使用 ”+“ 操作 ...

  9. SyntaxError: missing ; before statement

    做分页功能,遇到了很坑的事情.前台一直报错:SyntaxError: missing ; before statement 最后发现解决办法是eval("("+s+")& ...

随机推荐

  1. fcntl的区域锁定

    文件中的某个部分被锁定了,但其他的程序可以访问这个文件的其他部分,称为文件段锁定或文件区域锁定.经常使用文件区域锁定是fcntl函数. #include <sys/types.h> #in ...

  2. 在线sass编译器

    工作中,我们可能遇到突发情况(无法安装考拉,gulp以及webpack以及其它的自动化工具),我们这时就要用即时编译工具了,那么它就是你的首选: http://tool.oschina.net/

  3. web应用程序访问串口

    https://github.com/tylermenezes/SerialServe https://github.com/straend/SerialWebsocket http://www.cn ...

  4. 你的灯亮着吗pdf –读书笔记

      十句话概括这本书   1.确认问题比找到方法更重要 2.解决问题其实解决的是"人的期待" 3.你在解决问题中可能会发现新的机会 4.要了解问题的可变性和复杂性 5.站在用户而不 ...

  5. ElasticSearch异常归纳(能力工场小马哥)

    异常1: can not run elasticsearch as root [WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-2] ...

  6. 【Oracle】将表名与字段名连接成一行数据展示,字段名使用顿号的分隔

    select '<'||a.comments||'>:'||replace(wmsys.wm_concat(b.comments),',','.')||'.' as pjzf from u ...

  7. SET GLOBAL FOREIGN_KEY_CHECKS取消外键约束

    今天在工作中遇到的问题,在删除一个表时报错,发现有外键约束,所以不能删除,查了下发现需要取消外键约束. SET GLOBAL FOREIGN_KEY_CHECKS=0;全局取消外键约束 SET SES ...

  8. Drupal的$messages是怎么显示的?

    Drupal的默认主题bartik会在页面顶部显示系统信息,例如警告.状态等.这个过程是如何实现的? 首先,在bartik目录下找到page.tpl.php,这是bartik主题的页面显示模板.其中有 ...

  9. 错误号:1364 错误信息:Field &#39;platId&#39; doesn&#39;t have a default value

    1. 错误描写叙述 错误号:1364 错误信息:Field 'platId' doesn't have a default value insert into `use`.`t_platform_sc ...

  10. JavaScript中的闭包(closure)

    闭包的特性 1.函数嵌套函数 2.函数内部可以引用外部的参数和变量 3.参数和变量不会被垃圾回收机制回收  闭包的缺点就是常驻内存,会增大内存使用量,使用不当很容易造成内存泄露,主要用于私有的方法和变 ...