I have two arrays and I need to send the array values to PHP. When I print the value that returns from PHP, it prints an empty string. How can I get it? my code is below.
$.ajax({
type: "POST",
url: "test2.php",
data: {
price: [101, 69, 51],
id: [1, 2, 3]
},
success: function(response) {
alert(response);
}
});
In PHP
$id=mysql_real_escape_string($_POST['id'][0]);
echo $id;
Try running
var_dump($_POST). That way you can see exactly what the structure of the array is, so you know how to access it.