以下作品:
$("#txtAllowSearch").autocomplete(
{ source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"] }
);
但以下不起作用:
var $local_source = '["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]';
$("#txtAllowSearch").autocomplete(
{ source: $local_source }
);
我不熟悉数组。
答案 0 :(得分:5)
删除单引号:
var $local_source = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"];
否则$ local_source是一个不是数组的字符串。