Javascript 如何在JQuery中操作JSONArray

Javascript 如何在JQuery中操作JSONArray,javascript,php,jquery,json,Javascript,Php,Jquery,Json,我有一个php函数,它以JSON格式返回代码 {"0":{"title":"Dans l\u2019appartement"},"1":{"title":"A l\u2019a\u00e9roport - D\u00e9part de B\u00e9atrice"},"2":{"title":"Visite chez Jean-Louis"},"3":{"title":"Anita \u00e0 la matenit\u00e9"},"4":{"title":"Visite chez Jean-

我有一个php函数,它以JSON格式返回代码

{"0":{"title":"Dans l\u2019appartement"},"1":{"title":"A l\u2019a\u00e9roport - D\u00e9part de B\u00e9atrice"},"2":{"title":"Visite chez Jean-Louis"},"3":{"title":"Anita \u00e0 la matenit\u00e9"},"4":{"title":"Visite chez Jean-Louis 2"},"5":{"title":"H\u00e9l\u00e9na pr\u00e9sent\u00e9e \u00e0 la famille"},"6":{"title":"Chez des proches"},"7":{"title":"Soir\u00e9e souvenir avec un proche - Photos, histoires"},"8":{"title":"Douceline tenant un b\u00e9b\u00e9"},"9":{"title":"Visite chez Jean-Louis 3"},"10":{"title":"Bapt\u00eame de Alexandra - Dans l\u2019\u00e9glise"}}
我想在JQuery中进行操作,我已经做了,但它不起作用

$.each(json, function(item, value) {
            console.log(value);
                $.each(value, function() {
                   console.log(this.title);
                });
            });

任何想法都非常感谢

第一次遍历使用每种方法都会为您提供包含title字段值的对象

因此,只需使用以下方法获取值:

$.each(json, function(item, value) {
     alert(value.title);        
 });

这里假设blob的变量名为“json”,您就不能这样做吗` for(json中的var key){console.log(key+'title:'+json[key].title);}`如果你以对象数组的形式发送数据,它会简化一些事情,[{“title”:“…},{“title”:“…”}]我已经完成了你告诉我的,告诉我这个错误是“Uncaught TypeError:Cannot use'in'操作符在#中搜索“986”`你从AJAx调用中得到json的值。。。如果是,请确保使用数据类型:“json”。。。。或者您可以首先使用var JSON=$.parseJSON(数据)解析JSON数据;在我添加了解析行之后,它现在可以工作了,但是在我在ajax中调用的php函数中,我编写了echo json_encode($test),这还不够吗?这是服务器端必须的(发送json)。。。但是客户端脚本需要知道接收的数据的格式/类型。因此分析的必要性。。。。(如果您使用的是AJAX,我建议您改用
dataType:'json'