Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
I can not to get the POST value from ajax

I would like to get the value from ajax with post in php, but this is not working, here is my code:

<script type="text/javascript">
    function deletarPerson(id_person) {
        let pag = "<?php echo plugin_dir_url(__DIR__) . 'admin/'; ?>";
        jQuery.ajax({
            url: pag + "/config.php",
            method: "post",
            data: {
                id_person: id_person
            },
            dataType: "html",
            success: function(result) {
                <?php
                    $aux = $_POST['id_person'];
                ?>
                alert('<?php echo $aux ?>')
            },
        })
    }
</script>

Someone can help me?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your Javascript ajax code:

function deletarPerson(id_person) {
    jQuery.ajax({
        url: "/echo.php", // <-- sending to echo.php on the server
                          // ...use whatever PHP file, on the server, 
                          // you need to get the necessary information
        method: "post",
        data: {
            id_person: id_person
        },
        dataType: "text",
        success: function(result) {
            alert(result) // <-- now use Javascript and the result variable,
                          // which is text sent back from the server,
                          // and do what you need to with it on the client
        },
    })
}

...and your PHP file:

<!-- echo.php -->
<?php

$aux = $_POST['id_person'];
echo $aux; // <-- whatever is echo'ed or print'ed in this file 
           // gets sent back to the server as text 
           // and is loaded in the Javascript result variable

// OR you can actually get some useful information from the server 
// and send that back instead

?>

Read more about the distinct executions contexts between PHP on the server and Javascript/HTML/CSS... on the client.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda