
     window.onload = getLocation;
     
     function savePosition(position) {   
         $.ajax({
            url: "/profile/editLastCoord?lat="+position.coords.latitude+"&lng="+position.coords.longitude
            });
             }
      function errorCallback(pos) { console.log("Error happened on geolocation.watchPosition!"); }
      function getLocation() {
          if (navigator.geolocation) {
            watchOpts = {
              enableHighAccuracy:true,
              timeout:60000,
              maximumAge:0
            };
            navigator.geolocation.watchPosition(savePosition, errorCallback, watchOpts);
          } 
      }