Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var lat;
- var lng;
- $(document).ready(function(){
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(function(position) {
- lat = position.coords.latitude;
- lng = position.coords.longitude;
- }, function() {
- });
- } else {
- lat = '0';
- lng = '0';
- }
- if(lat != undefined){
- //Perform Ajax request.
- $.ajax({
- url: '<?= base_url() ?>index.php/home/latlng_session',
- type: 'get',
- data: {latitude: lat, longitude: lng},
- success: function(data){
- alert(lat+','+lng);
- },
- });
- }
- });
Add Comment
Please, Sign In to add comment