Jquery 反向JSON对象
嗨,我有一个JSON对象(“/successment\u ratings.JSON”): …一些html:Jquery 反向JSON对象,jquery,json,Jquery,Json,嗨,我有一个JSON对象(“/successment\u ratings.JSON”): …一些html: <div id="feedback"></div> 还有其他各种方式。我只是不知道该怎么做才能以相反的顺序遍历我的JSON对象。在使用每个 $.each(data.satisfaction_ratings.reverse(), function() { // console.log(this.comment); items.push("<
<div id="feedback"></div>
还有其他各种方式。我只是不知道该怎么做才能以相反的顺序遍历我的JSON对象。在使用
每个
$.each(data.satisfaction_ratings.reverse(), function() {
// console.log(this.comment);
items.push("<li>" + this.comment + "</li>");
});
$.each(data.successment\u ratings.reverse(),function()){
//console.log(this.comment);
items.push(“”+this.comment+“ ”);
});
var json={
“满意度评分”:[{
“id”:217414761,
“更新时间”:“2015-02-26T07:15:32Z”,
“评论”:“你太棒了!”
}, {
“id”:217419001,
“更新时间”:“2015-02-28T17:45:39Z”,
“评论”:“你太棒了!”
}, {
“id”:220481332,
“更新时间”:“2015-03-01T11:19:56Z”,
“评论”:“你真棒!”
}, {
“id”:218225121,
“更新时间”:“2015-03-02T05:36:08Z”,
“评论”:“你太棒了!”
}, {
“id”:228307861,
“更新时间”:“2015-03-25T18:39:47Z”,
“评论”:“你太棒了!”
}],
“下一页”:空,
“上一页”:空,
“计数”:5
};
$.each(json.successment\u ratings.reverse(),function()){
$('ul').append(''+this.comment+' ');
});代码>
在使用每个之前尝试反转阵列
$.each(data.satisfaction_ratings.reverse(), function() {
// console.log(this.comment);
items.push("<li>" + this.comment + "</li>");
});
$.each(data.successment\u ratings.reverse(),function()){
//console.log(this.comment);
items.push(“”+this.comment+“ ”);
});
var json={
“满意度评分”:[{
“id”:217414761,
“更新时间”:“2015-02-26T07:15:32Z”,
“评论”:“你太棒了!”
}, {
“id”:217419001,
“更新时间”:“2015-02-28T17:45:39Z”,
“评论”:“你太棒了!”
}, {
“id”:220481332,
“更新时间”:“2015-03-01T11:19:56Z”,
“评论”:“你真棒!”
}, {
“id”:218225121,
“更新时间”:“2015-03-02T05:36:08Z”,
“评论”:“你太棒了!”
}, {
“id”:228307861,
“更新时间”:“2015-03-25T18:39:47Z”,
“评论”:“你太棒了!”
}],
“下一页”:空,
“上一页”:空,
“计数”:5
};
$.each(json.successment\u ratings.reverse(),function()){
$('ul').append(''+this.comment+' ');
});代码>
$.reverse().each(data.satisfaction_ratings, function() {...});
Object.keys(data.satisfaction_ratings).sort().reverse().forEach(function(){...});
$.each(data.satisfaction_ratings.reverse(), function() {
// console.log(this.comment);
items.push("<li>" + this.comment + "</li>");
});