Jahia in English > Use json object...

0 (0 Good)
0 (0 Bad)

Use json object from ActionResult...

by  kissenlall »  2013/03/03 13:26

 

Hi.

I am currently returning a json object in my action result from an action. this redirects to a jsp page. I want to be able to access the json object returned from the action in this jsp page.

How to achieve that?

Many Thanks

Kissenlall

  (kissenlall)

Number of messages  7
Registration date
0 (0 Good)
0 (0 Bad)

Re: Use json object from ActionResult...

by  shuber »  2013/03/04 13:12

Hello,

Best way to do that is to use an AJAX request to call your action and then the JSON response becomes accessible through the AJAX response.

Best regards,

  Serge Huber.

Serge Huber (shuber)

Number of messages  271
Registration date
0 (0 Good)
0 (0 Bad)

Need help implementing the advice of JSon into Ajax call from ActionResult

by  rali »  2013/08/26 12:31

Hello, 

 

I am trying to do this same thing and the Json is not coming through. 

I've added code detial here. 

 

Ultimately :

 

JAVA.CLASS

.....
json.put("iTotalDisplayRecords", totalRows);
ActionResult result = new ActionResult(HttpServletResponse.SC_OK, null, json);
result.setJson(json);
return result;
 
JSP PAGE
$.post(${url.base}${currentNode.path}.javaAction.do, function(data) {$('#result').html(data);alert(data);});
 
 
Can you please help me?

  (rali)

Number of messages  8
Registration date
0 (0 Good)
0 (0 Bad)

answered

by  rali »  2013/08/26 15:13

That was the problem. I needed to have JSON (in quotes) in the Ajax call and I needed to call "data.info".

$.post(${url.base}${currentNode.path}.javaAction.do, function(data) {$('#result').html(data.info);alert(data.info);},"json");

THanks qlamerand

  (rali)

Number of messages  8
Registration date
Contact
Share
Feedback

Get in touch

Whether you are a current user or if you are just evaluating Jahia, we are here to help.

Contact us

Share this page