title: Passing javascript variables to another php page
body: <p>I have a select list where in using javascript i get the selected values i want this selected values to pass through php file init.php so that i can use those variables in mysql query.
  my javascript code is as follows:</p>
  
  <pre><code>                  $(document).ready(function(){ 
  
                   var e = document.getElementById("product");
                    var pro = e.options[e.selectedIndex].text;
                    alert(pro);
  
                   });
  
                   $('select').change(function(){ 
                    var e = document.getElementById("city");
                    var cit = e.options[e.selectedIndex].text;
                    alert(cit);
  </code></pre>
  
  <p>I have used ajax to send variables to init.php. my ajax code below is not working,can anyone tell whats the issue in this code:</p>
  
  <pre><code>                       $.ajax({
                           url: 'init.php',
                           type: 'POST',
                           data: { x:'cit',y:'pro' },
                           success: function(data) {
                             console.log(data);
  
                                }
                              });
  </code></pre>
  
  <p>and in init.php i have written : </p>
  
  <pre><code>&lt;?php
  $var1 = $_POST['y'];
  $var2 = $_POST['x'];
  $result = "Select amount from ". _DB_PREFIX_ ."demo_detail where product =    '". $var1 ."' and city = '" . $var2 . "' ";
  //echo json_encode($result);
  </code></pre>