Reputation: 119
I am trying to parse a jQuery initialized array to PHP with an AJAX POST. However, I am trying to alert the ToString()
of an array. Here is my ajax call, I am essentially trying to just take an array and pass it to my PHP for some further manipulation. Here is my code:
AllArray.push("Alim");
AllArray.push("Jonathon");
AllArray.push("Kyle");
var returnVal = AllArray.toString();
$.ajax({
type: "POST",
data: { 'allInfoArray' : returnVal },
success: function() {
console.log("AJAX Fired");
}
This is the PHP in my html file. I am trying to alert the array for debug purposes.
$allTeamArray = $_GET['allInfoArray'];
echo "<script type='text/javascript'>alert('$allTeamArray');</script>";
Upvotes: 1
Views: 617
Reputation: 32392
Your ajax call passes the value via POST
but you're alerting GET
, which is why your alert isn't displaying the expected data.
$allTeamArray = $_GET['allInfoArray'];
^ change to $_POST
Upvotes: 3