-
Dec 27th, 2011, 04:59 PM
#1
How to pass json to js function
I want to use the jquery datatables plugin along with Spring 3.1/json. I'm not sure the correct way to pass the data from the jsp page to the js function which will initialize the grid.
Can someone shed some light on this for me. I've verified that the object is making it to the jsp page. My questions what is the best way to read this object from the jsp into the javascript function and convert it to json? Should I convert it to json in java and pass it to the jsp as json store it as a hidden variable and read it into js? Should/can i read the object into javascript and then convert to json?
Any advice would be greatly appreciated.
Thank you.
Keith
-
Dec 28th, 2011, 05:08 AM
#2
Hi Keith,
in my opinion you should convert your object to JSON in the controller, provide via ViewModel and then parse with JQuery. Another approach valid for the long run (support filtering/paging without reloading the whole page again), would be rendering the JSP page and asynchronously loading the data afterwards. Then you could use the ContentNegotiationViewResolver and override the view twice like this: http://stackoverflow.com/questions/3...ing-on-request
Regards Johannes
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules