Hello all,
I've got a php array:
$toField = explode(",", $ids); //Which looks something like '24,25,26,29'
I want to pass this array via jQuery AJAX, with this:
<form id="myForm">
<input type="hidden" value="'.$toField.'">
<input type="submit" id="sendMessage" class="faceboxSubmit" name="ok" value="Send Reply"/>
</form>
And here's my jQuery:
$("#sendMessage").click(function(event){
event.preventDefault();
var senderID = <?php echo $usrID; ?>;
var receiverID = $("#toField").val();
$.ajax(
{
type: "POST",
url: "replyMessage.php",
data: "senderID=" + senderID + "&subject=" + subject + "&message=" + message + "&receiverID=" + receiverID + "&threadID=" + thread_id,
beforeSend: function() {
$("#sendingMessage").show();
},
success: function() {
alert("Success");
}
});
});
How can I pass the array, so that with the "replyMessage.php" page, I could take each ID from the Array, to do something like this:
<?php
foreach ($_POST['receiverID'] as $receiverID)
{
mysql_query //etc...
}
Any help is greatly appreciated!