SyntaxError: missing] after element list Firefox Problems

Source: Internet
Author: User

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.

 

 

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.