title: Pass data from javascript to php in the same page
body: <p>i want to make a function on my landing page that get the user location and calculate the nearest store and show it on the page.. im using this code to calculate..</p>
  
  <pre><code>var cities = [
       ["city1", 10, 50, "blah"],
       ["city2", 40, 60, "blah"],
       ["city3", 25, 10, "blah"],
  ];
  
  function NearestCity(latitude, longitude) {
      var mindif = 99999;
      var closest;
  
  for (index = 0; index &lt; cities.length; ++index) {
      var dif = PythagorasEquirectangular(latitude, longitude, cities[index][1], cities[index][2]);
      if (dif &lt; mindif) {
      closest = index;
      mindif = dif;
    }
  }
  
      alert(cities[closest]);
  }
  </code></pre>
  
  <p>how to pass the result to php and store to db?</p>