Twitter Bootstrap Typeahead不处理响应

时间:2012-07-16 10:57:38

标签: ajax spring-mvc twitter-bootstrap typeahead

我有Spring MVC控制器:

@Controller
@RequestMapping(value = "/bla")
public class TestController {       
    @RequestMapping(value = "json", method = RequestMethod.POST)
    public @ResponseBody String getJson(@ModelAttribute SearchQueryJson searchQueryJson) {
        System.out.println("hih");
        System.out.println(searchQueryJson.getQuery());     
        return new String("{'asd','asdd'}");
    }
}

和js:

<script>
    $("#searchbox").typeahead({
        source: function (typeahead, query) {
            return $.post("bla/json", { query: query }, function (data) {
                return typeahead.process(data);
            });
        }
    });
</script>

在google chrome调试器中我看到响应{'asd','asdd'},但没有任何反应(搜索框中的下拉菜单没有出现)!我正在使用twitter bootstrap typeahead (method 'toLowerCase' of undefined)https://gist.github.com/2712048

1 个答案:

答案 0 :(得分:1)

更改return typeahead.process(data);

return typeahead(data);