【发布时间】:2009-05-29 08:40:03
【问题描述】:
我有这个 php 代码
$ids = array(1,2,3);
$names = array("cat","elephant","cow");
$originalSettings = array ('ids'=>$ids,'names'=>$names);
$jsonSettings = json_encode($originalSettings);
echo $jsonSettings;
这是 jQuery 代码
$.post("ajax.php", {},
function(data){
data.ids.each(function(i) {
alert(data.names[i]);
}
//is it possible to receive the arrays and navigate them
}, "json");
如何使用 json 传递数组并在 javascript 中接收它们?
谢谢
【问题讨论】:
-
您的警报后缺少一个括号(调用
标签: php javascript jquery json