Devbridge Autocomplete适用于" lookup"但是当我切换到serviceUrl时,它没有显示结果。没有错误,json验证。
HTML:
<input type="text" name="currency" class="biginput" id="autocomplete" autocomplete="off">
JS:
$('#autocomplete').autocomplete({
//lookup: currencies,
serviceUrl: "http://localhost/agfg1Member/handlers/ACKeyword.ashx",
onSelect: function (suggestion) {
var thehtml = '<strong>Currency Name:</strong> ' + suggestion.value + ' <br> <strong>Symbol:</strong> ' + suggestion.data;
$('#outputcontent').html(thehtml);
},
dataType: 'jsonp',
minChars: 2 });
来自c#ashx处理程序的json示例
({"suggestions":[{"value":"Tuggerah","data":{"category":"Suburb","id":"3371","parentCat":"3"}},{"value":"Tuggeranong","data":{"category":"Suburb","id":"3372","parentCat":"80"}},{"value":"Tugun","data":{"category":"Suburb","id":"3373","parentCat":"33"}}]})
括号使它成为jsonp。这是JSONLINT验证没有括号:
{
"suggestions": [
{
"value": "Tuggerah",
"data": {
"category": "Suburb",
"id": "3371",
"parentCat": "3"
}
},
{
"value": "Tuggeranong",
"data": {
"category": "Suburb",
"id": "3372",
"parentCat": "80"
}
},
{
"value": "Tugun",
"data": {
"category": "Suburb",
"id": "3373",
"parentCat": "33"
}
}
]}
ashx文件输出context.Response.ContentType =&#34; application / json&#34 ;;
我尝试添加&#34; jsonp:&#39; cb&#39;&#34;到源代码,仍然没有。
使用jquery.1.9.1 此外,当单步执行javascript时,var响应仍然未定义。我不知道这意味着什么,但听起来并不好,嘿?