这里是我的jQuery来解析Json结果我从我的页面返回。如何使用jQuery解析Json结果
{ “结果”:真正的 “动作”: “添加”}
$ .parseJSON(数据)不解析它。我需要获得Result和Action值。
$("#favorite").click(function() {
$.getJSON('/review/favorite/[email protected](Model.Review.Id)', function (data) {
var result = $.parseJSON(data);
alert(result.Action);
if (result.result == true && result.action == "add") {
alert("add");
} else if (result.result == true && result.action == "delete") {
alert("delete");
}
});
return false;
});
jQuery已经解析了你的json,你不需要自己动手 – ori 2012-03-14 11:40:51
数据已经被解析;-) – clops 2012-03-14 11:41:54
就像@ori说的,getJSON已经将数据解析成一个对象。如果哟做着获得(),那么你就需要使用parseJSON上的数据,但因为你叫.getJSON你不需要。 – davidethell 2012-03-14 11:42:39