title: Take a lat/long pair from JavaScript for use in date_sunset in PHP
body: <p>I have decided i'd like to do an ambitious mood change depending on the time of day. I need to get the time and compare it against the sunset and sunrise of any given day. </p>
  
  <p>So far I have found some javascript <a href="http://www.maxmind.com/app/javascript_city" rel="nofollow">here</a> that works well. Can anyone tell me how I might give the lat and long to the PHP function date_sunset? I have the IP in a PHP variable using        <code>$_SERVER['REMOTE_ADDR']</code> but that's all I have. I can't really do much else as I have never used the function and never tried to combine PHP and JS. Any ideas?</p>
  
  <p>-- Update --</p>
  
  <p>I have been trying to use the jQuery $.ajax function. Here is my code;</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
  var lat = geoip_latitude();
  var long = geoip_longitude();
  $(document).ready(function(){
     //var url = 'http://www.ransomedesign.co.uk/web/?lat=' + lat + '&amp;long='+ long;
     // $.get(url);
    $.ajax({
    type: "GET",
    data: { lat:lat, long:long},
    url: "http:www.ransomedesign.co.uk/web/",
    success: function() { alert("you win"); }
    })
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>There are two different approaches in there. (1st one is commented out). This does populate my $_SERVER php code, but only on the 2nd request of a page for my site. I really need this to process on the first visit before anything loads. After this the value will be stored in a session and php will do the rest.</p>
  
  <p>Can anyone see whats wrong with this code or why it wont work straight away? My php if after this, is that correct?</p>
  
  <p>Many thanks...</p>