I have the following ajax code sending data to php via post:
checked_id = 10;
$.ajax({
url: "/delete_document",
type: "POST",
data: {id:checked_id}, // a
success: function(data, textStatus, jqXHR){
alert(data);
location.href='/delete_document';
},
error: function (jqXHR, textStatus, errorThrown){
//alert('Error!')
}
});
it prepares the data successfully, and the correct value is alerted (10).
Then i should fetch this value in the php file:
$selected_id = $_POST['id'];
var_dump($selected_id);
but var_dump gives me string(0) "".
I know that when the code doesn't work, it's always me the one that's doing it wrong. But I can really not see the mistake here.