<input type="text" id="name" name="name">
   <button id="submit">Ajax Call</button>
   </div>
  <div id="message"></div>
<script>
 $( document ).ready(function() {
    $("#submit").click(function(e)
    {
       $.ajax({
            type:"POST",
            url:"caltest.php",
            data:{name:$("#name").val()},
            success: function(result,status,xhr)
            {
                $("#message").html(result);
            },
            error:function(xhr,status,error)
            {
                $("#message").html(error);
            }
        });
    });
});

Source code for target page:-

caltest.php
<?php
$val = $_POST['name'];
echo $val;
?>
Please follow and like us:

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

RSS
Follow by Email