Ajax handles JSON array problems returned by PHP
{"Status": 1, "info": ["201209\/20120905rmyr8izms6.jpeg", "201209\/20120905b1i8bi1c9x.jpeg", "201209\/ 20120905z0zfdjuf61.jpeg "," 201209\/20120905144fn9ollz.jpeg "]," Data ":" "}
This is the returned data, info inside is an array, I want to use JS effect to turn over the picture, how can I get the picture of the following table and determine whether there is a previous or next picture
------Solution--------------------
My understanding is that you can first parse the JSON data into groups, and then you can get info data, according to the above format, subscript should be the number increment, starting from 0, you can get the length of the info array, you can get the last picture of the subscript, so whether it can be judged? As for the JSON data parsing array, you can go to the web to check, the package of many libraries, the common can be the next Json.js library (www.json.org), and then use String.parsejson () conversion.
In fact, like you said this effect, online should have a lot of examples, you can check the ~
------Solution--------------------
JScript code
var str= ' {"Status": 1, "info": ["201209\/ 20120905rmyr8izms6.jpeg "," 201209\/20120905b1i8bi1c9x.jpeg "," 201209\/20120905z0zfdjuf61.jpeg "," 201209\/ 20120905144fn9ollz.jpeg "]," Data ":"} ", var obj = eval (' (' + str + ') '), alert (obj.info.length),//info length 4var i=3;// Test the last element if ("undefined" = = typeof (Obj.info[(i+1))) {alert (321);} Else{alert (obj.info[(i))}