在jQuery中获取Json数据 [英] Get Json data in jQuery
本文介绍了在jQuery中获取Json数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
没有一个清晰的示例说明如何尽可能简单地提取json数据.我有一个有效的json,我需要使用jQuery进行检索
There is not a single clear example that explains how to pull json data as simple as possible. I have a valid json and I need to retrieve it with jQuery
我的json输出为:
{
"title": "blog entries",
"items" : [
{
"title": "Can Members of the Diaspora Work Effectively at th",
"date": "8/4/2009 9:42:38 AM"
},
{
"title": "Ashoka Brazil",
"date": "7/15/2009 8:56:12 AM"
},
{
"title": "Life Spring Hospital",
"date": "7/15/2009 8:56:12 AM"
},
{
"title": "Pozitron/Endeavor",
"date": "5/26/2009 8:58:39 PM"
}
]
}
我尝试通过以下方法来检索它,但没有运气.
I tried retrieving it with the following but no luck.
$.getJSON({
type: "GET",
data: { PROCESS: "ViewBlog" },
url: "http://www.pangeaadvisors.org/sep123/blog.cs.asp",
dataType: "json",
success: function(json) {
$(json).find('item').each(function(){
var title = $(this).find('title').text();
$('<div class="news_title"></div>').html(title).appendTo('#news_wrap');
});
}
});
推荐答案
尝试一下
var items = test.items;
$.each(items,function(index,items){
console.log(items.title); /// and items.date
})
这篇关于在jQuery中获取Json数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文