I am sending an array I have in javascript to php using:
usernames = ['username1','username2']
$.ajax({
url: "my_Url",
type: "post",
data: {username:usernames} ,
success: function (response) {
// you will get response from your php page (what you echo or print)
alert(response);
}
});
data will be sent to the php script containing what is below:
<?php
header('Access-Control-Allow-Origin: *');
$usernames = $_POST['username'];
echo $usernames;
?>
The problem is I get an alert saying Array but not what is in the actual array itself. How do I get what is inside the array and put it in a variable again.