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( AS rows FROM scrusersonline LEFT JOIN active_users ON 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= "
"; } else { $str2= "
"; } $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 答疑

    评论 抢沙发

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

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