I have this piece of code in my PHP code:
while ($row = mysqli_fetch_assoc($result))
{
extract($row);
echo \"\";
echo \"
-
Problem solved! Here is what i did.
Inside PHP file to create rows of dynamic checkboxes,
while ($row = mysqli_fetch_assoc($result))
{
extract($row);
echo "";
echo "$book_id ";
echo "$book_name ";
echo " ";
} // while
I do not use JQuery $.post method anymore. I changed my code to the following
var my_query_str = '';
$("input[@type='checkbox'][@name='books']").each(
function()
{
if(this.checked)
{
my_query_str += "&bookArray[]=" + this.value;
}
});
$.ajax(
{
type: "POST",
url: "saveBookList.php",
data: "dummy_data=a" + my_query_str,
success:
function(responseData)
{
$("#save-result").empty().append(responseData);
},
error:
function()
{
$("#save-result").append("An error occured during processing");
}
});
Now, inside saveBookList.php page, value of $_POST['bookArray'] is an Array. Yey! Yey!
I do hope and wish the $.post method of JQuery can support array data type as Prototype does. :)
- 热议问题