Reputation:
I have Spring MVC controller:
@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'}");
}
}
and js:
<script>
$("#searchbox").typeahead({
source: function (typeahead, query) {
return $.post("bla/json", { query: query }, function (data) {
return typeahead.process(data);
});
}
});
</script>
at google chrome debugger i see response {'asd','asdd'}, but nothing happens (dropdown at search box doesn't appears)! i'm using twitter bootstrap typeahead (method 'toLowerCase' of undefined) and https://gist.github.com/2712048
Upvotes: 3
Views: 1493
Reputation: 426
change return typeahead.process(data);
to return typeahead(data);
Upvotes: 1