I have this piece of code in my PHP code:
while ($row = mysqli_fetch_assoc($result))
{
extract($row);
echo "<tr>";
echo "<td bgcolor='#FFFFFF'><input id='bookArray[]' name='bookArray[]' type='checkbox' value='$book_id' />$book_id</td>";
echo "<td bgcolor='#FFFFFF'>$threat_name</td>";
echo "</tr>";
}
In HTML page, I want to use jQuery serialize() method to sent array of selected books in bookArray[]. In my JavaScript,
var selectedbooks = $("book_form").serialize();
alert (selectedbooks);
In the alert message box, i did not get any value (empty string).
Previously when i am using Prototype, it worked nicely.
I have come up with a method that will, when the data is sent using post
on the other side lets you access your elements using
$_['post']['name']
If it is an array (eg a multiple select) then on your server you can access it as an array again
$_POST['myselect'][0]...
Code: Function to serialize form data for post
jQuery 1.4
it's not a problem with jQuery Post, it's with serialize you can do this:
but all you really have to do is replace '[' & ']' back to themselves after serializing them. because serialize(); changed them to their htmlencoded value!
work correctly jquery =>
php =>
output =>
and You can do whatever what you want like with array data, thanks to Aridane https://stackoverflow.com/questions/1792603
easy:
serialize().replace(/%5B%5D/g, '[]')