title: Get position coordinates for an ajax request
body: <p>Currently working on a weather web-app for iOS. I'm trying to get the coordinates of the user and put the latitude and longitude in my Ajax request (on the api Wunderground) .</p>
  
  <p>Here's my code (EDIT): </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
         $(document).ready(function() {
  
         navigator.geolocation.getCurrentPosition(getLocation, unknownLocation);
  
           function getLocation(pos)
           {
             var lat = pos.coords.latitude;
             var lon = pos.coords.longitude;
  
              $.ajax({
                       url : "http://api.wunderground.com/api/ApiId/geolookup/conditions/q/"+ lat +","+ lon +".json",
                       dataType : "jsonp",
  
                       success : function(parsed_json) {
                          var location = parsed_json['location']['city'];
                          var temp_f = parsed_json['current_observation']['temp_f'];
                          alert("Current temperature in " + location + " is: " + temp_f);
                       }
                    });
           }
           function unknownLocation()
           {
             alert('Could not find location');
           }
         });
      &lt;/script&gt;
  </code></pre>
  
  <p>As you can see I "simply" have to create 2 vars lat and lon and add them in my request. I tried a lot of variants but I can't get this code working.</p>
  
  <p>Any idea of what I'm doing wrong ?</p>
  
  <p>Thank you very much !</p>