It's just me or it is really difficult to work with variables in javascript?
My problem is that I want to use some results of my javascript function into a MVC .net Controller, and I just can't!
1.- My JavaScript function runs on a view:
$(document).ready(function () {
$('#go').click(function () {
// test for presence of geolocation
if (navigator && navigator.geolocation) {
navigator.geolocation.getCurrentPosition(geo_success, geo_error);
} else {
// nothing at this moment.
......
function geo_success(position) {
printLatLong(position.coords.latitude, position.coords.longitude);
}
Besides printLatLong function, I want to use the argument position.coord.latitude to send it to a controller through Html.ActionLink like this:
@Html.ActionLink("Link to Controller", "Action", "Controller", position.coords.latitude)
But I can't use position.coords.latitude since now I'm out of the function. I just want to use that value as an argument in my ActionLink, is that too difficult?? :(
Thanks in advance for any help.