Get city name using geolocation via ajax - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajax

Description

Get city name using geolocation via ajax

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> 
  <script type="text/javascript">
    window.onload=function(){//from w  w w  . j  a v  a2s. c  o m
$.get("https://api.ipdata.co/?api-key=test", function (response) {
    $("#response").html(JSON.stringify(response, null, 4));
}, "jsonp");
    }

      </script> 
 </head> 
 <body> 
  <pre id="response"></pre>  
 </body>
</html>

Related Tutorials