内容简介:作为指南实现自动完成,因为它几乎与我需要的相同.我可能遗漏了一些“显而易见”的东西,因为我还不了解自动完成语法的所有部分.问题:我可以得到建议的下拉列表.但是一旦我得到了控制台中出错.
我环顾四周,无法找到问题的答案.我没有多少使用jquery UI,但我正在尝试使用此博客条目 jQuery UI Autocomplete with JSON in MVC 4
作为指南实现自动完成,因为它几乎与我需要的相同.我可能遗漏了一些“显而易见”的东西,因为我还不了解自动完成语法的所有部分.
问题:我可以得到建议的下拉列表.但是一旦我得到了
Uncaught TypeError: Property 'results' of object #<Object> is not a function
控制台中出错.
此外,虽然建议出现,我不能选择任何一个.一旦我尝试,清单就会消失.虽然这可能完全不同.
jqueryUI1.9.2代码中的错误位置是此代码段中的最后一行:
__response: function( content ) {
var message;
this._superApply( arguments );
if ( this.options.disabled || this.cancelSearch ) {
return;
}
if ( content && content.length ) {
message = this.options.messages.results( content.length );
我的jquery看起来像这样:
$("#FastCategory").autocomplete({
source: function (request, response) {
$.ajax({
url: "/Quiz/GetCategory",
type: "POST",
dataType: "json",
data: { term: request.term },
success: function (data) {
console.log("data=",data);
response($.map(data, function (item) {
console.log("item=",item,item.Description);
return { label: item.Description, value: item.Description };
}))
}
})
},
messages: {
noResults: "", results: ""
}
});
我的控制器看起来像这样:
public JsonResult GetCategory(string term)
{
var result = (from r in db.QuizCategories
where r.Description.ToLower().Contains(term.ToLower())
select new { r.Description }).Distinct();
return Json(result, JsonRequestBehavior.AllowGet);
}
知道我哪里错了吗?
以上所述就是小编给大家介绍的《JqueryUI自动完成错误:未捕获TypeError:对象#的属性“结果”不是函数》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Ordering Disorder
Khoi Vinh / New Riders Press / 2010-12-03 / USD 29.99
The grid has long been an invaluable tool for creating order out of chaos for designers of all kinds—from city planners to architects to typesetters and graphic artists. In recent years, web designers......一起来看看 《Ordering Disorder》 这本书的介绍吧!