0
我想在MVC2中实现Ajax自动完成,但没有成功。它没有进入自动完成。你能告诉我什么是错的吗?这是我的脚本。MVC2使用jQuery的Ajax自动完成
$('#Contact').change(function() {
debugger;
$('#Contact').autocomplete({
source: function (request, response) {
$.ajax({
url: "/ChapterRelationship/GetContacts",
data: {searchText: request.term, maxResults: 10},
type: "POST", // http method
datatype: "json",
success: function (msg) {
// ajax call has returned
var result = msg;
var a = [];
if (result !== null) {
for (var i = 0; i < result.length; i++) {
a.push({ label: result[i].prop1, id: result[i].prop2 });
}
} responseFn(a);
}
});
}
});
});
这是我的控制器。
[HttpPost]
public JsonResult GetContacts(string id)
{
// return Content("test");
return this.Json("test", JsonRequestBehavior.AllowGet);
}
感谢