Skip to main content
se añadieron 2400 caracteres en el cuerpo
Origen Enlace
<?php!DOCTYPE html>
if(isset($_POST["id_dato"])){<html lang="es">
    echo<head>
 $_POST["id_dato"];       <meta charset="UTF-8">
}        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Probando Jquery</title>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
    </head>
    <body>
        <main>
            <h1>ENVIAR VARIABLE POST JQUERY AJAX</h1>
            <input type="hidden" class="form-control d-none" id="inputName" value="1">
            <button class="btn btn-primary" id="btnEditar">editar</button>
        </main>

        <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
        <script src="controller.js"></script>
        <!-- LLAMO A MI ARCHIVO PHP PARA MOSTRAR LA VARIABLE POST-->
        <?php require_once "controller.php"?>
    </body>
</html>

Por:

<?php!DOCTYPE html>
if(!empty($_POST)){<html lang="es">
    echo<head>
 $_POST["id_dato"];       <meta charset="UTF-8">
}        <meta name="viewport" content="width=device-width, initial-scale=1.0">
?>        <title>Probando Jquery</title>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
        <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
        <script src="controller.js"></script>
    </head>
    <body>
        <main>
            <h1>ENVIAR VARIABLE POST JQUERY AJAX</h1>
            <input type="hidden" class="form-control d-none" id="inputName" value="1">
            <button class="btn btn-primary" id="btnEditar">editar</button>
        </main>
    </body>
</html>
<?php 
if(isset($_POST["id_dato"])){
    echo $_POST["id_dato"];
}
?>

Por

<?php 
if(!empty($_POST)){
    echo $_POST["id_dato"];
}
?>
<!DOCTYPE html>
<html lang="es">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Probando Jquery</title>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
    </head>
    <body>
        <main>
            <h1>ENVIAR VARIABLE POST JQUERY AJAX</h1>
            <input type="hidden" class="form-control d-none" id="inputName" value="1">
            <button class="btn btn-primary" id="btnEditar">editar</button>
        </main>

        <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
        <script src="controller.js"></script>
        <!-- LLAMO A MI ARCHIVO PHP PARA MOSTRAR LA VARIABLE POST-->
        <?php require_once "controller.php"?>
    </body>
</html>

Por:

<!DOCTYPE html>
<html lang="es">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Probando Jquery</title>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
        <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
        <script src="controller.js"></script>
    </head>
    <body>
        <main>
            <h1>ENVIAR VARIABLE POST JQUERY AJAX</h1>
            <input type="hidden" class="form-control d-none" id="inputName" value="1">
            <button class="btn btn-primary" id="btnEditar">editar</button>
        </main>
    </body>
</html>
Origen Enlace

1.- revisa tu consola en el apartado de Red/xhr/encabezados y revisa si se esta enviando la variable id_dato=1.

2.- cambia

<?php 
if(isset($_POST["id_dato"])){
    echo $_POST["id_dato"];
}
?>

Por

<?php 
if(!empty($_POST)){
    echo $_POST["id_dato"];
}
?>