Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to pass a variable in jQuery from PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 289
    Comment on it

    Hello Reader's! If you want to send variables from PHP to jQuery then you have to use the selectors:-

    Lets's see the example below:-

    This you have to put in the bottom of php page with the selector is "input[type=checkbox]"

    $("input[type=checkbox]").click(function () {
       $.post('my_ajax_receiver.php', 'val=' + $(this).val(), function (response) {
          alert(response);
       });
    });
    
    //PHP file my_ajax_receiver.php
    <?php
       $value = $_POST['val'];
       echo "I got your value! $value";
    ?>
    

    Now every time you give input in the php file it will pass it to another page.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: