如何通过使用jQuery我JSON响应循环? [英] How to loop through my Json response using jQuery?

查看:93
本文介绍了如何通过使用jQuery我JSON响应循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的JSON响应如下:

My Json response looks like:

[{"UserID": 1}, {"UserID", 324}]

我所说的页面以获取JSON这样的:

I call the page to get json like:

$.get("myurl.aspx", {blah:1}, function(data) {

       $.each(data.items, function(i, item) {
             alert(item.UserID);

       });

});

萤火虫报告错误:

Firebug is reporting the error:

G是不确定的。

推荐答案

我想你想这不是因为你的数据的VAR没有一个属性调用项目:

I think you want this instead since your data var doesn't have a property called items:

$.each(data, function(i, item) {
     alert(item.UserID);
});

这篇关于如何通过使用jQuery我JSON响应循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆