2
有教程那里解释如何做到这一点,如here和here的一大堆。jQuery的自动完成功能无法与JSON数据工作
看起来真正的轻松吧?然而,我仍然设法浪费了半天的时间而没有做任何事情。
例如:下面的作品精绝
public ActionResult FindStuff(string q)
{
return Content("test");
}
$('#MyTextBox').autocomplete("MyController/FindStuff", {
parse: function(data) {
alert('parsing');
}
});
如果我将其更改为以下,绝对没有任何反应。
public JsonResult FindStuff(string q)
{
return Json(new { name = "test" });
}
$('#MyTextBox').autocomplete("MyController/FindStuff", {
dataType: 'json', // I've also tried with this line commented out
parse: function(data) {
alert('parsing');
}
});
所以它看起来像parse
呼叫不会被击中,也就是我假设的数据负载莫名其妙地吹起来或者认为没有数据。有任何想法吗?谢谢。
p.s.它的乔恩Zaefferer插件here。
该死JsonRequestBehavior!这不是第一次让我受益。 – fearofawhackplanet 2010-07-28 12:12:33
这就是为什么萤火虫是非常有用的。你立即得到错误。 – 2010-07-28 12:36:19