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>";
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.