• Friday , 29 May 2020

JavaScript: Post to PHP (AJAX)

Code Canyon



A video tutorial showing you how to post JavaScript variables to PHP using AJAX

http://www.abell12.com
http://www.twitter.com/abell12youtube
http://www.facebook.com/pages/Abell12/265102633605437

Original source

3d Ocean

Related Posts

20 Comments

  1. Abel Alexander
    May 2, 2019 at 17:27

    Thanks man!

  2. David Weiler
    May 2, 2019 at 17:27

    is it possible to send html arrays to php?

  3. Rahul Khan
    May 2, 2019 at 17:27

    why its not working in newer versions of php

  4. Sudhanshu Singh
    May 2, 2019 at 17:27

    its JQUERY :'( not vanilla javascript!!! CHEATER

  5. Gothic Truth
    May 2, 2019 at 17:27

    THANK YOU BRO!!!!!!!!!! THAAAAAAANKS!!!!!!!!!!!!!!!! 🙂

  6. hitesh batra
    May 2, 2019 at 17:27

    Nice work
    but my content which is echoed is not shown or sometimes it just shown and vanishes please help me out

  7. Michael Avalos-Garcia
    May 2, 2019 at 17:27

    where did you declare the variable data?

  8. Dean O'Rourke
    May 2, 2019 at 17:27

    Great video!!

    I have a question, if I wanted to use this on a link instead of a button like the video, how could I get it to work? I've tried embedding the $.post function from your video into a click function for the link so far and it works by getting the elementID (a unique id for that anchor tag) and storing it in a variable. This part works. However, getting it to post to my php file thus far has been unsuccessful . It's for a project in college so any help at all would be appreciated!!

  9. Tylan Coleman
    May 2, 2019 at 17:27

    How can I attache this form to an array?

  10. Tylan Coleman
    May 2, 2019 at 17:27

    Thanks for this

  11. MY _ DIXIE _ RECT
    May 2, 2019 at 17:27

    Nice video

  12. ZoommaiR
    May 2, 2019 at 17:27

    This is great if you want to use JQuery, I just don't.

  13. Moahmed Bozgia
    May 2, 2019 at 17:27

    saved my day ! very helpful thank you

  14. Manoj Bharti
    May 2, 2019 at 17:27

    you are a legend dude

  15. Hamada Saidi
    May 2, 2019 at 17:27

    its jQuery Gandalf!

  16. Bielan Camilo Neres
    May 2, 2019 at 17:27

    very good, tks

  17. Xes webmaster
    May 2, 2019 at 17:27

    Hi even if I copy your code 100% except for <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script&gt;

    It does nothing any advice?

    <head>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script&gt;

    </head>

    <body>

    <form>

    <input type="text" id="name" placeholder="name">

    <input type="text" id="age" placeholder="age">

    <input type="button" value="submit" onclick="post();">

    </form>

    <div id="result"></div>

    <script type="text/javascript">

    function post()

    {

    var name =$('#name').val();

    var age =$('#age').val();

    alert('name s = ' + name);

    $.post('validate.php',{postname:name,postage:age},

    funtion(data)

    {

    if(data=="1")

    {

    $('#result').html('You are over 18');

    }

    if(data=="0")

    {

    $('#result').html('You are under 18');

    }

    });

    }

    </script>

    //validate.php
    <?php

    $name = $_POST['postname'];

    $age = $_POST['postage'];

    if ($age >=18)

    {

    echo "1";

    }

    else

    {

    echo "0";

    }

    ?>

  18. fuzzy buddy
    May 2, 2019 at 17:27

    could you please provide source code

  19. Ali Fakhoury
    May 2, 2019 at 17:27

    Are you coding on a river?

  20. Crisper Lawas
    May 2, 2019 at 17:27

    can I get js variable to php without submitting?

Leave A Comment

You must be logged in to post a comment.