不知道为什么这不再是数组并且 {},{} 之间没有逗号
foreach ($query->result_array() as $row) {
header("Content-type: application/json");
echo (json_encode($row,JSON_PRETTY_PRINT));
}
以及如何在 jquery 中提醒 json 数据?在此之前,我在 js 中使用 for 循环来循环它,但由于某种原因,我现在必须在服务器端循环。
已编辑
//because i want to replace $row['url'] to get_thumb();
foreach($query->result_array() as $row){
$row['url'] = $this->vz_image->get_thumb($row['url'],'n');
header("Content-type: application/json");
echo (json_encode($row,JSON_PRETTY_PRINT));
}
然后我得到了这个结果,但我不知道如何在 jquery 中提醒这个 json 数据。有什么帮助吗?
{
"id": "44",
"url": "assets\/img\/uploaded_photos\/thumbs\/1358786330_n.jpg",
"created_time": "1358786330",
"photo_id": "170",
"tag_id": "44",
"name": "Lan Yao Yeng",
"num_photo": "3"
}{
"id": "44",
"url": "assets\/img\/uploaded_photos\/thumbs\/1358711532_n.jpg",
"created_time": "1358711532",
"photo_id": "169",
"tag_id": "44",
"name": "Lan Yao Yeng",
"num_photo": "3"
}