[Javascript-debug-ajax-json] Two different JSON format data

Source: Internet
Author: User

Bug 1:

1. The data in this is just a one-dimensional array
{"state": 0, "ErrorCode": 0, "data": {"Originalname": "", "Name": "3e12cdbd9d855449440035b3fdaf78bd.png", "url"
: "Images\/release\/3\/d\/3e12cdbd9d855449440035b3fdaf78bd.png", "Real_url": "Http:\/\/cache.hinabian.com
\/images\/release\/3\/d\/3e12cdbd9d855449440035b3fdaf78bd.png "," size ": 94064," type ":". png "," state ":" SUCCESS "
}}


2. The data in this is a two-dimensional array, is not good to hear is the background is the two-dimensional array is encoded in JSON format, the return of the
{"state": 0, "ErrorCode": 0, "data": [{"f_id": "1", "F_brand": "Dada", "F_name": "\u4ef7\u503c110\u5143\u7684\u55d2\ u55d2\u5df4\u58eb\u4ee3\u91d1\u5238\u5957\u7968\u4e00\u5957 "," F_no ":" $ "," f_img ":" Dd110.png "," F_qrcode ":" Ddqr.png "}]}

Bug 2:

1. Note The data format returned by Ajax after the PHP request, and the value obtained through Array.indexof () is surprising.

var arr_real = [' 2 ', ' 3 ', ' 4 ', ' 11 ']; A string array of JavaScript
var id = json_msg.data.f_id;
Console.log (Arr_real.indexof (ID)!==-1); True/false

2. Note the data format returned by Ajax after the PHP request, and the value obtained through Array.indexof () is surprising.

var arr_real = [2, 3, 4, 11]; A numeric array of javascript
var id = json_msg.data.f_id;
Console.log (Arr_real.indexof (ID)!==-1); False

[Javascript-debug-ajax-json] Two different JSON format data

Related Article

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.