在jQuery中获取Json数据

在jQuery中获取Json数据,jquery,json,Jquery,Json,没有一个清晰的例子解释如何尽可能简单地提取json数据。我有一个有效的json,需要用jQuery检索它 我的json输出如下: { "title": "blog entries", "items" : [ { "title": "Can Members of the Diaspora Work Effectively at th", "date": "8/4/2009 9:42:38 AM" },

没有一个清晰的例子解释如何尽可能简单地提取json数据。我有一个有效的json,需要用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"
        }
    ]
}
我试着用以下方法找回它,但没有成功

    $.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');
            });
        }
    });
更新

它失败了,因为你的url中有两个点

假设请求工作正常,检查firebug以查看请求是否作为脚本标记发出&您需要执行的操作是返回响应

$.each( json.items, function(){

   ...

});
或者您可以使用普通js

for (var i=0; i<json.items.length; i++) {

   ...

}
试试这个

$.getJSON("http://www.pangeaadvisors.org/sep123/blog.cs.asp",{ PROCESS: "ViewBlog" }, function(json) {
                    for (var i = 0; i < json.length; i++) {
                        var title = json[i].Title;
                        $('<div class="news_title"></div>').html(title).appendTo('#news_wrap');
                    }
            });

正如redsquare回答您需要或$。每个:

您必须了解如何使用ajax进行跨域调用。这样做的请求将被浏览器拒绝。

试试这个

var items = test.items;
$.each(items,function(index,items){
    console.log(items.title); /// and items.date
})

还是没什么。你自己看看:你能使用完整的jquery版本吗?这样我就可以调试了。min版本让它变得很难!另外,您不需要为getJson函数传递类型和数据类型,这不是问题所在,但是,它在一个正则表达式上失败,该正则表达式的URL替换为完整版本的jquery。另外,删除了gettype和type。仍然不起作用。有办法解决这个问题吗?