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)])}