I am trying to send a javascript array to an external php page, but the only thing the php page is picking up is the fact that I am sending array, not the actual data within the array.
javascript –
var newArray = [1, 2, 3, 4, 5];
$.ajax({
type: 'POST',
url: 'array.php',
data: {'something': newArray},
success: function(){
alert("sent");
}
});
External PHP Page –
<?php
echo($_POST['something']));
?>
I know this question has been asked before, but for some reason, this isn’t working for me. I have spent the last couple days trying to figure this out as well. Can someone please point me in the right direction.
current output (from php page) –
Array (thats all the page outputs)
You should use
var_dumpin stead ofecho.Echo is only for strings, integers, floats and it will print 1 if a boolean is TRUE, and Array for an array.