jquery - Reading the JSON data -
i trying send data controller view in spring mvc using json, here code in controller:
@requestmapping(value="/twitter/searchgeomap", method=requestmethod.get) public string twittersearchgeojson(@requestparam("query") string query) throws twitterexception { list<status> tweets = twitterservice.twittersearchgeo(query); list<string> geolist = new arraylist<string>(); jsonobject json = new jsonobject(); (status tweet : tweets) { geolocation geo = tweet.getgeolocation(); string latitude = string.valueof(geo.getlatitude()); string longitude = string.valueof(geo.getlongitude()); string text = tweet.gettext(); string place = tweet.getplace().tostring(); geolist.add(text); geolist.add(latitude); geolist.add(longitude); geolist.add(place); string key = string.valueof(tweet.getid()); json.accumulate(key, geolist); } return json.tostring(); }
and here how read json in view:
$(document).ready(function() { $.getjson("searchgeomap?query=obama", function(data){ console.log("hi"); }); });
the first question how can set parameter (query) wont need put request "searchgeomap?query=obama"? , other problem console.log("hi");
not work , cannot see output in console, why nothing inside function gets executed? doing wrong?
i think missing @responsebody annotation in controller signature, this
public @responsebody string twittersearchgeojson(@requestparam("query") string query) throws twitterexception
Comments
Post a Comment