Test Geoloc

function showError(error) { switch (error.code) { case error.PERMISSION_DENIED: document.getElementById("location").innerHTML = "User denied the request for Geolocation."; break; case error.POSITION_UNAVAILABLE: document.getElementById("location").innerHTML = "Location information is unavailable."; break; case error.TIMEOUT: document.getElementById("location").innerHTML = "The request to get user location timed out."; break; case error.UNKNOWN_ERROR: document.getElementById("location").innerHTML = "An unknown error occurred."; break; } }

function sendLocationToServer(latitude, longitude) { // You need to make an AJAX request to a server-side script (e.g., PHP) to send the email with the location data. // Here's a simple example using jQuery for the AJAX request: $.post("send_location.php", { latitude: latitude, longitude: longitude }, function(response) { // Handle the server response here if (response === "success") { alert("Location data sent successfully!"); } else { alert("Failed to send location data."); } }); }

Tinggalkan komentar