About Firefox execute var obj = eval (' (' + data + ') '); times syntaxerror:missing] After element list error, chrome and IE normal
The situation is as follows:
When using AJAX to receive JSON data passed from the background
$.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 ("error");}});
When SET datatype: "JSON", the program jumps to the error
When removing datatype: "JSON", syntaxerror:missing] after element list error
Struts is configured as:
<struts><package name= "Build" extends= "Json-default" ><action name= "registeraction" method= "register "class=" com.home.RegisterAction "> <result type=" JSON "></result></action></package ></struts>
action is (part of the 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 questions about Firefox error is: Set dataType to HTML or text can be
Generated syntaxerror:missing] After element list problems are not necessarily the same as in this example
It is also possible that, due to other problems, the consolidation example does not necessarily have a public nature, but also requires specific analysis of specific problems.
Itmyhome
Source: http://blog.csdn.net/itmyhome1990/article/details/41977941
Welcome to join the Java Technology Exchange Group: 74955800
Syntaxerror:missing] After element list Firefox problem