Syntaxerror:missing] After element list Firefox problem

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.