Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!