Find user address by IP to display a modal

Asked

Viewed 46 times

0

Good afternoon, I would like to take the values of user geolocation and display a model if it is in a certain location, I can get the values of coordinates, but how do I pass php these values that are in javascript?

<div> 
    <p id="demo">Clique no botão para receber sua localização em Latitude e Longitude:</p>
    <button onclick="getLocation()">Clique Aqui</button>
    <script>
        var x=document.getElementById("demo");
        function getLocation()
        {
            if (navigator.geolocation)
            {
                navigator.geolocation.getCurrentPosition(showPosition);
            }
            else{x.innerHTML="O seu navegador não suporta Geolocalização.";}
        }
        function showPosition(position)
        {
            x.innerHTML="Latitude: " + position.coords.latitude +
                "<br>Longitude: " + position.coords.longitude;
        }
    </script>

  • using the so-called ajax

  • I’ll try, thank you

  • Make a GET or POST request to your php

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.