3

私は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のブートストラップタイプアヘッド(未定義のメソッド「toLowerCase」)https://gist.github.com/2712048を使用しています

4

1 に答える 1

1

変化するreturn typeahead.process(data);

return typeahead(data);

于 2012-12-04T05:30:52.423 に答える