0
我目前從服務器得到以下數據傳回:從JSON數據中提取所需的部分?
{
"d": [
{
"__type": "Conflict",
"Group": "Clients",
"Count": 284
},
{
"__type": "Conflict",
"Group": "Addresses",
"Count": 127
},
{
"__type": "Conflict",
"Group": "Matters",
"Count": 287
},
{
"__type": "Conflict",
"Group": "Individuals",
"Count": 500
},
{
"__type": "Conflict",
"Group": "Organisations",
"Count": 107
}
]
}
我知道如何使用jQuery顯示第一Group
值:
$.ajax({
type: 'POST',
url: 'conflict.asmx/GetConflicts',
data: '{phrase: "john"}',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(conflicts) {
if(conflicts.d[0]) {
alert(conflicts.d[0].Group) ;
} else {
alert ("null");
}
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message) ;
}
});
如何在Group
顯示所有的價值觀和Count
?例如:
Clients: 284
Addresses: 127
Matters: 287
Individuals: 500
Organisations: 107