Eval-related problems when ajax callback function return value processing

Source: Internet
Author: User
The eval problem occurred when processing the ajax callback function return value. it has been detected and processed successfully: var & nbsp; reseval ([{fid: 3, sid: 3, sonName: 1st chemistry}, {content: & lt; p & gt; & lt; img & nbsp; alt & nbsp; srclist. image. eval problems when processing the return value of the baid ajax callback function
Detected and processed:

Var res = eval ("(" [{"fid": "3", "sid": "3", "sonName": "1st chemistry "}, {"content ":'

Wwwwrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrqqq

'}, {"Content ":'

Bytes

'}] ")");



Failed to be detected (not executed): var res = eval ("("

[{"Fid": "3", "sid": "10", "sonName": "4th chemistry" },{ "content ":'

'}, {"Content ":'

Dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd



Sdddddddddddddddddddddddddd

'}]

")");



Let's take a look at why eval cannot be used to process the second ajax return value?

------ Solution --------------------
JavaScript strings do not contain line breaks. if necessary, escape them.

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.