Reputation: 115
I am sending array via ajax to PHP. How to get the array from PHP?
$('.send-image').on('click', function() {
$.ajax({
type:"POST",
url:"sendimages.php",
data: {
images: imgArr
},
success: function(data) {
console.log(data);
},
error: function(e) {
console.log(e);
}
});
});
I tried with this, but its not working
$images = $_POST['imgArr'];
foreach($images as $d) {
echo $d;
}
Upvotes: 1
Views: 55
Reputation: 15131
Replace
$images = $_POST['imgArr'];
With
$images = $_POST['images'];
Because the index images
came from here:
data: {
images: imgArr
}
Upvotes: 3