【发布时间】:2016-12-20 10:33:21
【问题描述】:
虽然 JQuery 有自动提示功能,但 Wu Yuntao 分叉的 Drew Wilson 版本更加通用。
但是在引用外部数据源时我不能让它工作
为了简单起见:
客户端部分:
<!doctype HTML><meta charset="UTF-8"><HEAD>
<link rel="stylesheet" href="jquery.autoSuggest.css?v=1">
<script src="jquery-3.1.0.min.js"></script>
<script src="jquery.autoSuggest.js"></script>
</head><Body>
<script>
$(document).ready(function(){
$("input[type=text]").autoSuggest("http://localhost/test/FindData.asp", {selectedItemProp: "name", searchObjProps: "name"});
})
</script>
Testing:
<form><input type=text></form></body>
而且数据源非常简单:
<%
response.contentType = "application/json"
JSON= "{""items"": [{""value"": ""21"", ""name"": ""Mick Jagger""},{""value"": ""43"", ""name"": ""Johnny Storm""}]}"
response.write JSON
%>
产量:
{"items": [{"value": "21", "name": "Mick Jagger"},{"value": "43", "name": "Johnny Storm"}]}
我错过了什么?
【问题讨论】:
-
缺少
",因此在最后一个代码块中突出显示了“奇怪”的语法;) -
是的,第一个值后面缺少引号。
-
@Andreas:'text' 周围缺少引号是允许的,并且没有任何改变,是的,带有经典 ASP 的 JSON 没问题。
-
@Dijkgraaf,是的,“值”末尾缺少引号中存在输入错误。然而,这改变了注意。数据集在在线验证器上验证没有问题。
标签: jquery json asp-classic autosuggest