这是一个从asp.net webservice返回的JSON对象。
[{"fullname":"martin","isAdmin":false,"Latitude":47,"Longitude":-124,"isOnline":false},
{"fullname":"melvyn","isAdmin":false,"Latitude":47,"Longitude":-124,"isOnline":true},
{"fullname":"simon","isAdmin":false,"Latitude":47,"Longitude":-124,"isOnline":false}]
当我在jquery中使用警报时
$(function () {
$("#btnShow").click(function () {
$.ajax(
{
type: "POST",
url: "WS_PfaMembers.asmx/GetPFAMembersForMap",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg);
},
failure: function (msg) {
alert('error');
}
});
});
});
msg
的提醒正在提供object Object
。
如何解析对象?
答案 0 :(得分:0)
您将无法打印出已返回的JSON对象,并希望仅使用对象上的警报直接获取其内容。你可以做的是使用jQuery.parseJSON方法解析代码。看看:
答案 1 :(得分:0)
答案 2 :(得分:0)
你是什么意思解析。如果你想迭代json对象.. ??
如果有的话,试试这个
success : function(msg){
$.each(msg , function(){
$.each(this , function(i,value){
console.log('The value of : ' + i + ' is - ' + value);
});
});
}