I need to send a group of checkboxes (with some other data as well) via ajax in jquery.
What I’ve done so far is:
var arr = $('#somediv input[type="checkbox"]:checked').val() || [];
$.post("/somephpfile.php", {str: str, arr: arr}, function(data) {...
But my problem is that the arr is never an array. What I need is to send it as ?str=data&arr=foo&arr=bar
I guess this is a very simple question, but since I am very new to jquery I’ll ask the pros.
How should I do it?
Thank you.
My bad, it was the php
You may be looking for .serialize
A more generic solution would be to have a form with all the parameters and then serialize it.