Answers for "how to use jquery variable in php"

PHP
-1

how to use jquery variable in php

Try this one:

<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
  var id = 23; 
$("#submit").click(function(){
 $.ajax(
    {
    url: "B.php",
    type: "POST",

    data: { id1: id},
    success: function (result) {
            alert('success');

    }
});     
   });
  });
 </script>
 </head>
 <body>
 <form  >
 <input type="button" id="submit" name="submit"/> 
 </form>
 </body>
 </html>
Then B.php

<?php
   $a =isset($_POST['id1'])?$_POST['id1']:'not yet';
   echo $a ;
   ?>
Posted by: Guest on July-13-2021

Code answers related to "how to use jquery variable in php"

Browse Popular Code Answers by Language