Answer the question
In order to leave comments, you need to log in
How to pass variables from js to Ruby on Rails controller?
I'm trying to solve the problem of determining the user's geolocation to display the correct content.
I made the definition of the city by ip, but the accuracy suffers. There are 50 to 50 hits from computers, and 0 from mobile devices with 3G. As an option, I decided to add a city definition by coordinates (navigator.geolocation).
I did something like this in js
$(document).ready(function() {
if(navigator.geolocation)
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question