Answers for "jquery variable php"

PHP
3

using js variable in php

<script type="text/javascript">
var abc= 'this is text';
<?php $abc = "<script>document.write(abc)</script>"?>   
</script>
<?php echo $abc;?>
Posted by: Guest on June-10-2020
-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 "jquery variable php"

Browse Popular Code Answers by Language