how to use jquery variable in php

Solutions on MaxInterview for how to use jquery variable in php by the best coders in the world

showing results for - "how to use jquery variable in php"
Eloane
20 Oct 2017
1Try this one:
2
3<html>
4<head>
5<script src="jquery.js"></script>
6<script>
7$(document).ready(function(){
8  var id = 23; 
9$("#submit").click(function(){
10 $.ajax(
11    {
12    url: "B.php",
13    type: "POST",
14
15    data: { id1: id},
16    success: function (result) {
17            alert('success');
18
19    }
20});     
21   });
22  });
23 </script>
24 </head>
25 <body>
26 <form  >
27 <input type="button" id="submit" name="submit"/> 
28 </form>
29 </body>
30 </html>
31Then B.php
32
33<?php
34   $a =isset($_POST['id1'])?$_POST['id1']:'not yet';
35   echo $a ;
36   ?>