在询问之前我想说这不是一个重复的话题。 我已经尝试过了:
Pwarelis的叉子 Tcrosen的一个 Gudbergur的代码......还有很多其他人,我也阅读了很多问答 ,但这些都不是我想要的。 我尝试的所有内容都与预定义的字符串源一起使用,但是当我执行下一步:AJAX远程源时,它只是在下拉列表中显示没有结果。
更新 - 我的代码 (不明白为什么负面投票。写得好,结构良好;))
html文件
<html> <head> <link href="./bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" /> </head> <body> <input id="myElement" class="typeahead" type="text"> <script src="./js/jquery.js"></script> <script src="./bootstrap/js/bootstrap-typeahead.js"></script> <script language="javascript"> $('#myElement').typeahead({ ajax: '/php/ajax.php' }); </script> [...]ajax.php文件:
<?php echo "[{ id: 1, name: 'Terry'}, { id: 2, name: 'Mark'}, { id: 3, name: 'Jack'}]"; ?>这不是AJAX问题,因为它在其他情况下在同一台机器上工作。 我可以尝试修理它吗?几天后我真的崩溃了。 谢谢阅读。
Before asking I want to say that this is not a duplicated topic. I've already tried with:
Pwarelis' fork Tcrosen's one Gudbergur's code...and many others, and I also read lots of Q&A, but none of them is what I am looking for. All what I tried works with predefinite string sources, but when I do the next step: AJAX remote source, it is just showing no results on the dropdown list.
UPDATE - My code (don't understand why negative votes. Well written, well strucuted ;))
The html file
<html> <head> <link href="./bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" /> </head> <body> <input id="myElement" class="typeahead" type="text"> <script src="./js/jquery.js"></script> <script src="./bootstrap/js/bootstrap-typeahead.js"></script> <script language="javascript"> $('#myElement').typeahead({ ajax: '/php/ajax.php' }); </script> [...]The ajax.php file:
<?php echo "[{ id: 1, name: 'Terry'}, { id: 2, name: 'Mark'}, { id: 3, name: 'Jack'}]"; ?>It's not an AJAX issue, because it is working in other cases at the same machine. What may I try to fix it?, I am really crashing up my head since a few days. Thanks for reading.
最满意答案
在不知道正确答案的情况下投票否定的人应该在采取行动之前先思考一下。 如果有人需要一个真正的漂亮/工作/魔术自动完成脚本,那么我们去:
真正好的自动完成脚本
说明 :这会向文本字段添加建议值的下拉菜单。 用户可以直接单击建议将其输入到字段中,也可以使用向上和向下箭头键导航列表,使用回车键选择值。 建议列表的值将以XML或JSON (通过PHP脚本或类似方式)提供 。
谢谢那些消极点消失的人;)
People who vote negative without even knowing the right answer should think a bit before acting. If someone needs a real nice/working/magic autocomplete script, here wo go:
Real good Autocomplete Script
Description: This adds a pulldown menu of suggested values to a text field. The user can either click directly on a suggestion to enter it into the field, or navigate the list using the up and down arrow keys, selecting a value using the enter key. The values for the suggestion list are to provided as XML, or as JSON (by a PHP script, or similar).
Thanks those who made negative points disappear ;)
更多推荐
发布评论