This is my code, I store on a local storage and I want it to pass to a php file it seems succesful because the alert "alert("Do something with example.php response");" pop-up. But when it directed to the next page there's an error: Notice: Undefined index: datas in C:\xampp\htdocs\final-project\placenameclick.php on line 183
$(".passdata").click(function () {
var currentplaceind = parseInt($(this).data("indes"));
localStorage.setItem("p", currentplaceind);
var data1 = localStorage.getItem("p");
jQuery.post("placenameclick.php", {datas: data1}, function()
{
alert("Do something with example.php response");
window.location = 'placenameclick.php';
})
.fail(function()
{
alert("Damn, something broke");
});
}
heres my code on the placenameclick.php
<?php
$data = $_POST['datas'];
$results = $pdo->query("SELECT * FROM places WHERE place_id = $data");
while ($row = $results->fetch()) {
include("places.php");
}
?>