难过:无法通过jQuery UI自动完成功能显示结果 [英] Stumped: cannot get results to show with jQuery UI Autocomplete
本文介绍了难过:无法通过jQuery UI自动完成功能显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用jquery自动完成功能举了一个简单的示例,但无法使其正常工作.我不知道JSON有什么问题,没有错误,也没有错,但是它不显示结果.
I threw up a simple example with jquery autocomplete and cannot get it to work. I have no idea what's wrong, no errors and nothing's wrong with my JSON, yet it doesn't display results.
这是我的代码
<div class="demo">
<div class="ui-widget">
<label for="title">Title: </label>
<input id="test" />
</div>
<script>
$(function() {
$( "#test" ).autocomplete({
source: "/searchbackend.php"
});
});
</script>
JSON:
{"title":["Metroid: Other M"]}
推荐答案
我想您的输出应该像这样["HELLO","HOW","DO","YOU","DO","?"]
,所以请使用1d数组输出json.
I guess your output should be like this ["HELLO","HOW","DO","YOU","DO","?"]
so use 1d array to output json.
$array = array("HELLO", "HOW", "DO", "YOU", "DO", "?");
echo json_encode($array);
男人..这很好用.
$array = array(
array("label" => "HELLO", "value" => "H"),
array("label" => "HOW", "value" => "H"),
array("label" => "DO", "value" => "D"),
array("label" => "YOU", "value" => "Y"),
array("label" => "DO", "value" => "D"));
echo json_encode($array);
还尝试将source: "/searchbackend.php"
更改为source: "searchbackend.php"
这篇关于难过:无法通过jQuery UI自动完成功能显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文