java - How to create a Jahia Ajax Call (JSP,JQuery) -
when build module/component need pass actionresult in order recieve proper httpservletrequest in ajax call?
for instance (in jsp):
var location = '${currentnode.path}.sqlpaging.do'; $.post(location, function(data) { temp=data; alert(data.info); $('#result').html(data); });
further information (here class):
@override public actionresult doexecute(httpservletrequest req, rendercontext rendercontext, resource resource, jcrsessionwrapper session, map<string, list<string>> parameters, urlresolver urlresolver) throws exception { jsonobject json = new jsonobject(); json.put("info",3.14); actionresult result = new actionresult(httpservletresponse.sc_ok, null, json); result.setjson(json); return result; }
packages used: javax.servlet.http org.jahia.bin.actionresult org.json.jsonobject
that problem. needed have json (in quotes) in ajax call , needed call "data.info".
var location = '${currentnode.path}.sqlpaging.do'; $.post(location, function(data) { temp=data; alert(data.info); $('#result').html(data); },"json");
thanks qlamerand
Comments
Post a Comment