我试图改变一个var来获取和卡住
这就是我所做的:
var choices = [['Australia', 'au'], ['Austria', 'at'], ['Brasil', 'br']];
所以这是有效的,我想在
上更改它$.getJSON('/modules/profile/readCountry.php',function(data){
arrays = data;
});
var choices = arrays;
但无效
php文件是:
foreach($countryies as $countr => $countrv) {
$json[] = array($countrv,$countr);
}
header("Content-type:application/json");
$out = array_values($json);
echo json_encode($out);
,输出为:
[['Australia', 'au'], ['Austria', 'at'], ['Brasil', 'br']]
如何清除缺少或不起作用的内容?
答案 0 :(得分:0)
$。getJSON是异步调用
var choices = [];
$.getJSON('/modules/profile/readCountry.php',function(data){
choices = data;
// do something with array
});