【发布时间】:2015-07-20 09:31:10
【问题描述】:
我是 jQuery 新手,希望有人能帮助我。
我有一个带有成功函数 (data) 的 Ajax 调用,它返回一个如下所示的数组。
现在我必须循环遍历它,并且对于每个“tID”,我必须对相应的“内容”做一些事情。
我正在考虑使用类似以下的东西,但不知道如何在这里应用它:
$.ajax({
type: "post",
url: "ajax.php",
cache: "false",
data: {
node: 'fetchContent',
tIDs: tIDs
},
success: function(data){
$.each(data.arr, function(index, value){
console.log(value.content);
});
}
});
有人可以帮我吗?
示例数组(Ajax 结果):
array(3) {
[0]=>
array(2) {
["tID"]=>
int(1)
["content"]=>
string(6) "Value1"
}
[1]=>
array(2) {
["tID"]=>
int(2)
["content"]=>
string(6) "Value2"
}
[2]=>
array(2) {
["tID"]=>
int(3)
["content"]=>
string(6) "Value3"
}
}
提前非常感谢。
【问题讨论】:
-
.ajax.php以什么格式返回您的数据? -
你能发布实际的回复吗?无论当前采用何种格式,都很难阅读。
-
@RoryMcCrossan:这是我发布的示例数组。
-
@George:我认为这与 Rory 的问题相同。我更新了帖子以更好地展示这一点。