更新:
非常感谢您的回复,我现在有了这段代码:
success: function (data) {
$.each(data, function (id, event)
var test = data.approved
if (test == "1") {
alert('approved')
}
);
}
以下是我的JSON示例:
{“id”:“174”,“title”:“John Smith”,“start”:“2013-04-03 00:00:00”,“end”:“2013-04-05 00: 00:00“,”fullname“:”John Smith“,”已批准“:”1“}, {“id”:“175”,“title”:“John Smith”,“start”:“2012-12-25 00:00:00”,“end”:“2012-12-27 00:00:00 “,”fullname“:”John Smith“,”已批准“:”0“}, {“id”:“176”,“title”:“John Smith”,“start”:“2012-12-28 00:00:00”,“end”:“2012-12-28 00:00:00 “,”fullname“:”John Smith“,”已批准“:”1“}, {“id”:“177”,“title”:“John Smith”,“start”:“2012-12-29 00:00:00”,“end”:“2012-12-29 00:00:00 “,”fullname“:”John Smith“,”已批准“:”0“}, {“id”:“178”,“title”:“John Smith”,“start”:“2012-12-21 00:00:00”,“end”:“2012-12-22 00:00:00 “,”“fullname”:“John Smith”,“已批准”:“1”}
如果活动已获得JSON批准,您能否告知我如何获得批准的提醒?
再次非常感谢
答案 0 :(得分:1)
您应该能够访问这样的数据 -
success: function(data) {
var event = data.approved;
if(event == "1") {
// do stuff
}
}
这是应该有效的代码 -
success: function(data) {
$.each(data, function() {
$.each(this, function(k, v) {
if((k == 'approved') && (v == '1')) {
alert('approved!')
}
});
});
}