Problems related to ajax processing of json arrays returned by php

Source: Internet
Author: User
Ajax handles the json Array returned by php {& quot; status & quot;: 1, & quot; info & quot;: [& quot; 201209 \/20120905rmyr8iZMs6.jpeg & quot ;, & quot; 201209 \/2 ajax processing of json arrays returned by php
{"Status": 1, "info": ["201209 \/20120905rmyr8iZMs6.jpeg", "201209 \/20120905b1i8bI1C9x.jpeg", "201209 \/20120905Z0zFDjUF61.jpeg ", & quot; 201209 \/20120905144fN9oLlz.jpeg & quot;], & quot; data & quot;: & quot ":""}


This is the returned data. info contains an array. I want to use js special effects to flip the image. how can I get the following table of the image and determine if there is any previous or next image?

------ Solution --------------------
In my understanding, we can first parse the json data into an array, and then we can get the info data. according to the above format, the subscript should be incremental, starting from 0, you can get the length of the info array and the subscript of the last image. can this be determined? As for the json data parsing array, you can check it online. There are many encapsulated libraries. Commonly, you can use the next json. js library (www.json.org) and convert it with string. parseJSON.
As you said, there should be many examples on the Internet ~
------ Solution --------------------
JScript code
Var str = '{"status": 1, "info": ["201209 \/20120905rmyr8iZMs6.jpeg", "201209 \/20120905b1i8bI1C9x.jpeg", "201209 \/second ", "201209 \/20120905144fN9oLlz.jpeg"], "data": ""} '; var obj = eval (' + str + '); alert (obj.info. length); // info the length is 4var I = 3; // test the last element if ("undefined" = typeof (obj.info [(I + 1)]) {alert (321);} else {alert (obj.info [(I)])}

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.