So I have a table in a jsp page with several rows and checkboxes for each row. I created a js function that creates an array of the value on the checkboxes. I want to send this array over in an ajax call so I toJson-ed it but I dont understand how actionbean variables get set with these parameters. Can anyone help? THANKS!
Java – Stripes & jQuery – how do i sent over variable in an ajax request
javajqueryjsonstripes
Related Topic
- Javascript – How to check if an element is hidden in jQuery
- Javascript – How to manage a redirect request after a jQuery Ajax call
- Javascript – Abort Ajax requests using jQuery
- Javascript – How to know which radio button is selected via jQuery
- Javascript – How to check whether a checkbox is checked in jQuery
- Jquery – How to select an element with multiple classes in jQuery
- Javascript – How to determine if a variable is ‘undefined’ or ‘null’
- Javascript – How to refresh a page with jQuery
Best Answer
Good question. Typically you create instance variables on your action beans, expose w/ getter/setters, and they are populated automagically via form post params or get params.
If you had a small handful of checkboxes, you could make a boolean for each one on your ActionBean, then your ajax call could be to a URL like "
Preferences.action?box1=true&box2=false&box3=false
".If you had a ton, you could create a List on the ActionBean. I've only dealt w/ this the non-ajax way, but you'd set the name attribute on the checkbox to something like this:
name="preferences[0]"
. I think you could do a jquery ajax call this way too, but you might have to url encode the name of the param.I think you could also look into the jquery form plugin to simply POST the json over.