2012-07-16 70 views
3

我有Spring MVC的控制器:Twitter的引導事先鍵入的內容不處理響應

@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> 

在谷歌瀏覽器的調試器,我看到的響應{ 'ASD', 'asdd'} ,但沒有任何反應(搜索框下拉不出現)!我使用twitter bootstrap typeahead (method 'toLowerCase' of undefined)https://gist.github.com/2712048

回答

1

變化return typeahead.process(data);

return typeahead(data);

相關問題