PHPでは、foreachから配列を取得しています。 JSONをエンコードしてすべての結果を一度に表示しています。これは正常に動作します。しかし、foreachがまだ続行しているので、配列アイテムを1つずつ表示する必要がある場合はどうすればよいですか?foreach配列アイテムを1つ1つajaxで表示する
<?php
$array = //somearray;
$data_arr = array();
foreach($array as $arr){
//do something
$data_arr[] = $arr;
}
echo json_encode(array('success'=>true,'data'=>$data_arr));
//here i can display the data in my jquery using each function
//i can display the whole data at once after the foreach is completed
//what i need is i want to display first element of data_arr after its loop is completed and then the second element and so on
?>
あなたは –
あなたはjqueryの応答でそれぞれを使用することができます持っているコードを提供してください。 –
foreachの内側にループするforeachを追加します。 –