大家好,我知道这个话题已经有一些结果了,但我现在还不打算做什么高级的东西,只是想了解一些基础知识。出于某种原因,这段代码中警报可以正常工作并打印出正确的数组信息,但我似乎无法让它为自动完成工作?https://jqueryui.com/autocomplete/
var oReq = new XMLHttpRequest(); //New request object
oReq.onload = function() {
var res = oReq.responseText;
AC(res);
};
oReq.open("get", "get-data.php", false);
oReq.send();
function AC(res){
$(function() {
alert(res);
$( "#tags" ).autocomplete({
source: res
});
});
}
那么在函数AC()中,alert(res)有效,但仍未填充源?
我的get-data.php文件如下:
<?php $arr = array("ActionScript",
"AppleScript",
"Asp");
echo json_encode($arr); ?>
我很感激您能提供任何帮助和指引,即使我需要去查找更多相关资料。