我在使用jQuery/Ajax/JSON时遇到了问题。类似于以下方式,我正在使用jQuery ajax post...
$.ajax({
type: "POST",
dataType: "json",
url: "someurl.com",
data: "cmd="+escape(me.cmd)+"&q="+q+"&"+me.args,
success: function(objJSON){
blah blah...
}
});
我的理解是这将返回一个JavaScript JSON对象?ajax post生成的文本如下(我认为这是有效的JSON)...
{
"student":{
"id": 456,
"full_name": "GOOBER, ANGELA",
"user_id": "2733245678",
"stin": "2733212346"
},
"student":{
"id": 123,
"full_name": "BOB, STEVE",
"user_id": "abc213",
"stin": "9040923411"
}
}
我似乎无法弄清楚如何解析由jQuery ajax post返回的JSON对象...基本上,我想循环遍历每个返回的学生,并制作一个div,就像这样...
$("<div id=\"" + student.id + "\">" + student.full_name + " (" + student.user_id + " - " + student.stin + ")</div>")
我似乎无法弄清楚如何做到这一点...
谢谢!