Navigates rather than executing
Hi,
I'm using following code to detect location and update accordingly. If I put this code in separate js it works perfectly, however when I put this inside html file (which improved the performance of site drastically), it navigates to index.html rather than executing the call back function show_map. Please help.
$('#btnLocationUpdate').live('click', function (e) {
alert('updating location'); // this works perfect
if (Modernizr.geolocation) { // from here, it navigates
navigator.geolocation.getCurrentPosition(show_map);
}
else {
alert('Location not supported');
}
});
function show_map(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var locationUpdateUrl = 'locate updated to server';
alert(locationUpdateUrl);
$.ajax({ type: 'GET', contentType: 'application/json', dataType: 'json', url: locationUpdateUrl, success: onUpdateSuccess });
}
function onUpdateSuccess(result) {
if (result.code == 200) {
alert('Located now');
}
}