Answer the question
In order to leave comments, you need to log in
How to send the value received using a function in js to the server?
There is a code:
navigator.geolocation.getCurrentPosition(
function(position) {
alert('Последний раз вас засекали здесь: ' +
position.coords.latitude + ", " + position.coords.longitude);
}
);
Answer the question
In order to leave comments, you need to log in
navigator.geolocation.getCurrentPosition(
function(position) {
$.ajax({
url: '/api/setPosition',
data: {lat: position.coords.latitude, lng: position.coords.longitude},
method: 'post',
success: function (response) {
console.log('success');
},
error: function (error) {
console.error(error);
}
});
}
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question