how to return multiple array items using json/jquery

Hey guys, quick question, I have a query that will usually return multiple results from a database, while I know how to return one result, I am not sure how to return multiple in jquery. I just want to take each of the returned results and run them through my prepare function. I have been trying to use 'for' to handle the array of data but I don't think it can work since I am returning different array values. If anyone has any suggestions, I would really appreciate it. **JQUERY RETRIEVAL** success: function(json) { for(i=0; i < json.rows; i++) { $('#users_online').append(online_users(json[i])); $('#online_list-' + count2).fadeIn(1500); } } **PHP PROCESSING** $qryuserscount1="SELECT active_users.username,COUNT(scrusersonline.id) AS rows FROM scrusersonline LEFT JOIN active_users ON scrusersonline.id=active_users.id WHERE topic_id='$topic_id'"; $userscount1=mysql_query($qryuserscount1); while ($row = mysql_fetch_array($userscount1)) { $onlineuser= $row['username']; $rows=$row['rows']; if ($username==$onlineuser){ $str2= "
$onlineuser
"; } else { $str2= "
$onlineuser
"; } $data['rows']=$rows; $data['entry']=$str1.$str2; } **EDIT ONLINE USERS FUNCTION** function online_users(response) { count2++; var string = '
  • ' + ''+response.entry+'' +'
  • '; return string; }
    Could you share some more code? The code snippet you provided doesn't show us what is inside online_users ( is it a function? ) or the values inside of json

    以上就是how to return multiple array items using json/jquery的详细内容,更多请关注web前端其它相关文章!

    赞(0) 打赏
    未经允许不得转载:web前端首页 » jQuery 答疑

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址

    前端开发相关广告投放 更专业 更精准

    联系我们

    觉得文章有用就打赏一下文章作者

    支付宝扫一扫打赏

    微信扫一扫打赏