我正在使用RoR和Jquery编写自动填充字段。
当我致电getJson
时:
var aeropuertos;
$.getJSON('web_services/get_airports', function(data) {
aeropuertos = data;
});
$("#airports_input_origen").autocomplete({source:aeropuertos});
$("#airports_input_destino").autocomplete({source:aeropuertos});
我明白了:
[
[
"(GKA)",
"GOROKA",
"GOROKA",
"PAPUA NEW GUINEA"
],
[
"(LAE)",
"LAE",
"PAPUA NEW GUINEA",
"00"
],
[
"(MAG)",
"MADANG",
"MADANG",
"PAPUA NEW GUINEA"
],
[
"(HGU)",
"MOUNT HAGEN",
"MOUNT HAGEN",
"PAPUA NEW GUINEA"
],
[
"(LAE)",
"NADZAB",
"NADZAB",
"PAPUA NEW GUINEA"
]
]
但似乎格式不正确,因为自动完成功能不起作用并且抛出此错误:
this.source不是函数
-----------------已解决--------------
这是一个JSON格式问题!
而不是发送[[“”,“”,...],...]
我必须发送:[“.......”,“.........”,....]
无论如何,谢谢你的时间! =)