2
public ViewResult Products()
public PartialViewResult AddProduct()
public JsonResult AutoComplete(string prefix)
查看
我加载在主视图模式弹出的局部视图(AddProduct.cshtml
)。
在部分视图中我有一个表单,我试图在输入字段添加jQuery UI自动完成,但它不工作。
$(function() {
$("#txtProductName").autocomplete({
source: function(request, response) {
$.ajax({
url: '/Admin/AutoComplete/',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function(data) {
response($.map(data, function(item) {
return item;
}))
},
error: function(response) {
alert(response.responseText);
},
failure: function(response) {
alert(response.responseText);
}
});
},
minLength: 1
});
});
我已经添加在局部视图页面本身这jQuery代码,还当我试图使用太不工作
控制台中的任何错误? “自动完成不是功能”还是没有错误? – adiga
没有错误我已经写了console.log,但它没有在控制台中打印,所以自动完成不会被触发 –
现在我在控制台中出现此错误“产品:1未捕获TypeError:autocomplete不是HTMLInputElement.onclick(产品:1 )“ –