SyntaxError: missing] after element list Firefox Problems
When Firefox executes var obj = eval ('+ data + '),SyntaxError: missing] after element listError. Chrome and IE are normal.
The scenario is as follows:
When ajax is used to receive json data transmitted from the background
$. Ajax ({type: POST, dataType: json, url: RegisterAction. action, data: params, success: function (data) {console. log (data); var obj = eval ('+ data +'); lele.info (obj) ;}, error: function (data, status, e) {alert (error );}});
When dataType: json is set, the program jumps to error.
When dataType: json is removed, the program reports the SyntaxError: missing] after element list error.
Struts Configuration:
Action is (part of code ):
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;}
To solve the above problem, set dataType to html or text.
The cause of the problem caused by SyntaxError: missing] after element list is not necessarily the same as that in this example.
It may also be caused by other problems. The fixed examples may not be public and need to be analyzed in detail.