Este es el código ajax: al clickear sobre un botón se abre esa función y guarda en una variable llamada id el id de ese botón. Luego se supone que con ajax se envía esa id a form.php pero me aparece el siguiente error:
Notice: Undefined index: id
$("button").click(function(){
var id = $(this).attr("id");
$.ajax({
url: 'form.php',
method: "POST",
data: {id : id},
success: function() {
$("#form").load("form.php");
}
});
});
Aquí el código PHP de form.php
<?php
// Initialize the session
session_start();
// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
header("location: login.php");
exit;
}
$id = $_POST['id'];
echo $id;
?>
Gracias