/
Index.html
42 lines (33 loc) 路 891 Bytes
/
Index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<html>
<body>
<p id="demo"></p>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
var x = document.getElementById("demo");
function getLocation() {
console.log ('runs');
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
getLocation();
function showPosition(position)
{
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
$.ajax({
method: "POST",
url: "/submitCoords",
data: { lat: position.coords.latitude, lon: position.coords.longitude }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
}
</script>
</body>
</html>