您可以按照以下方式进行操作。
PHP
$query = 'SELECt * FROM picture order by rand() LIMIT 10';$res = mysql_query($query);$pictures = array();while ($row = mysql_fetch_array($res)) { $picture = array( "pic_location" => $row['pic_location'], "name" => $row['name'], "age" => $row['age'], "gender" => $row['gender'] ); $pictures[] = $picture;}echo json_enpre($pictures);JS
...$.ajax({ ... dataType: "json", ... success: function(pictures){ $.each(pictures, function(idx, picture){ // picture.pic_location // picture.name // picture.age // picture.gender }); }});...


