Answer the question
In order to leave comments, you need to log in
How to transfer the defined city to a variable?
When visiting the page, the city is determined, but I need to pass this city to $_SESSION['city'], I can't figure out how.
<script src="https://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU" type="text/javascript"></script>
<script>
$(document).ready(function(){
ymaps.ready(function(){
var geolocation = ymaps.geolocation;
$('#city').text('Город: '+geolocation.city);
});});
</script>
<div id="city"></div>
Answer the question
In order to leave comments, you need to log in
$.ajax({
method: "POST",
url: "some.php",
data: { city: geolocation.city }
})
$_SESSION['city'] = $_POST['city']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question