I am looking for a way to save the values ββof all existing flags of a given class into some list or array and send the result via jquery to the asp.net mvc controller. Flags do not need to be checked, I need all of them.
More details:
My flags are as follows
<input type="checkbox" value="1" class="a-checkbox" <input type="checkbox" value="2" class="a-checkbox" <input type="checkbox" value="3" class="a-checkbox"
It would be nice if my MVC controller could look like this:
public JsonResult SaveList(List<String> values) {
I know that I can access the cells as follows
$('input.a-checkbox').each( function () {
But I do not know how to create such a data structure. could you help me?
thanks
Edit: nice, thanks. Can you tell me what's wrong with that? My controller is called really, but the list is null (server side)
var list = []; $('a-checkbox').each( function () { list.push($(this).val()); } ); $.ajax({ type: "POST", url: myUrl, data: list, success: function (data) { alert(data.Result); }, dataType: "json", traditional: true });
source share