Guest User

Untitled

a guest
Feb 20th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. var lat;
  2. var lng;
  3.  
  4. $(document).ready(function(){
  5. if (navigator.geolocation) {
  6. navigator.geolocation.getCurrentPosition(function(position) {
  7.  
  8. lat = position.coords.latitude;
  9. lng = position.coords.longitude;
  10.  
  11. }, function() {
  12.  
  13. });
  14. } else {
  15. lat = '0';
  16. lng = '0';
  17. }
  18.  
  19. if(lat != undefined){
  20. //Perform Ajax request.
  21. $.ajax({
  22. url: '<?= base_url() ?>index.php/home/latlng_session',
  23. type: 'get',
  24. data: {latitude: lat, longitude: lng},
  25.  
  26. success: function(data){
  27. alert(lat+','+lng);
  28. },
  29. });
  30. }
  31.  
  32.  
  33.  
  34. });
Add Comment
Please, Sign In to add comment