"John","time"=>"2pm"), array("name"=>"2","ti-6ren">
gpt4 book ai didi

php - jQuery $.get() 数组返回 [object Object]

转载 作者:行者123 更新时间:2023-12-01 06:17:54 24 4
gpt4 key购买 nike

test.php 包括:

echo json_encode( array(
array("name"=>"John","time"=>"2pm"),
array("name"=>"2","time"=>"1242pm"),
array("name"=>"J231ohn","time"=>"2p213m"),
));

jQuery:

$.get("test.php", function(data) {
$.each(data, function(n, val) {
alert(n + ': ' + val)
});
}, "json");

这是结果:

0: [object Object]
1: [object Object]
2: [object Object]

我做错了什么?

最佳答案

尝试:

alert(n + ': name = ' + val.name + ' time = ' + val.time);

关于php - jQuery $.get() 数组返回 [object Object],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5095741/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com