mardi 25 septembre 2018

how to keep asking user to allow location in browser [duplicate]

This question already has an answer here:

is there any solution to keep ask user allow location in browser if is say no my code needs to access location of user to work

    <script>

$(document).ready(function(){
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showLocation);
    } else { 
        $('#location').html('Geolocation is not supported by this browser.');
    }
});

function showLocation(position) {

    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;


    $.ajax({
        type:'POST',
        url:'/location',
        data:'latitude='+latitude+'&longitude='+longitude,
        success:function(msg){
            if(msg){
            }else{
            }
        }
    });

}
</script>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire