我有一个 PHP 脚本,它返回一个 json 编码的结果,如下所示:
// I added "var jsonp =" manually to make it an array variable.
var jsonp = [
[
{
"txtHide": "Y",
"data": "2012-12-21",
"phone": "+15879891300",
"Text": "Hello"
},
{
"txtHide": "Y",
"data": "2013-01-08",
"phone": "+15879891400",
"Text": "Issue"
},
{
"txtHide": "Y",
"data": "2013-01-19",
"phone": "+15879891040",
"Text": "This is a test "
}
],
[],
[
{
"txtHide": "Y",
"data": "2013-01-16",
"phone": "+142610588790",
"Text": "kkk 1"
},
{
"txtHide": "Y",
"data": "2013-01-18",
"phone": "+123610588790",
"Text": "Test 23"
},
{
"txtHide": "N",
"data": "2013-01-22",
"phone": "+123610588790",
"Text": "Hi"
}
],
[],
[],
[],
[
{
"txtHide": "Y",
"data": "2013-01-05",
"phone": "+221522988655",
"Text": "oo 12"
}
]
]
如何使用 JQuery 遍历这个 JSON 结果?
这是我所做的,但它只打印前四行:
$.each(jsonp, function(i,val) {
console.log(val[i].txtshare);
console.log(val[i].dtzserver);
console.log(val[i].txtphonee164);
console.log(val[i].txtfinding);
});
我的 Firebug 控制台输出:
Y
2012-12-21
+15879891300
Hello