急,谁用过jq的autocomplete插件,调用页显示不了咋回事?
<script type='text/javascript' src='static/javascript/jquery.js'></script>
<script type='text/javascript' src="static/javascript/query.ui.widget.js"></script>
<script type='text/javascript' src="static/javascript/jquery.ui.core.js"></script>
<script type='text/javascript' src="static/javascript/jquery.ui.position.js"></script>
<script type='text/javascript' src='static/javascript/jquery.ui.autocomplete.js'></script>
</head>
<body>
<input type="text" name="query" id="query" />
<script type="text/javascript">
$(function(){
$("#query").autocomplete({
source: "query.php",
minLength:2
});
});
</script>
</body>
</html>
------------------
query.php的数据读取正常,也得到了正确格式的json值。但是在上面页面的输入框中输入的时候,没有任何下拉补全内容出现。按更应当是在输入时不断执行jquery.ui.autocomplete.js里的函数才是,但发现只在页面载入时访问一次,后面输入的时候不再访问。难不成没有成功绑定事件?
------解决方案--------------------
JScript code
<script type="text/javascript">
$(document).ready(function() {
$("#txtAuto").focus().autocomplete("../WebService/AutoGetData.ashx", {
delay: 10,
minChars: 1,
autoFill: true,
max: 10000,
formatResult: function(row) {
return row[0].split(",")[0];
},
autoFill: false
})
});
</script>
------解决方案--------------------
query.php返回是json就错了。应该是Array(数组) 比如官方例子的数据["ActionScript","AppleScript","Asp","BASIC","C","C++","Clojure","COBOL","ColdFusion","Erlang","Fortran","Groovy","Haskell","Java","JavaScript","Lisp","Perl","PHP","Python","Ruby","Scala","Scheme"]
------解决方案--------------------
如何用JS写出一个弹出对话框,请各位帮忙。
------解决方案--------------------
如果因为中文问题,一是统一编码是首选。二是把中文编码json_encode 如把"这里是中文标题" 转成 "\u8fd9\u91cc\u662f\u4e2d\u6587\u6807\u9898"