<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> </div> </nav> <div class="col-md-6 well"> <hr style="border-top:1px dotted #ccc;"/> <div class="col-md-3"> </div> <div class="col-md-9"> <table class="table table-bordered"> <thead class="alert-info"> <tr> </tr> </thead> </table> </div> </div> </body> </html>
$(document).ready(function(){ $('#detect').on('click', function(){ var data = ""; $('#result').html("<tr><td colspan='6'><center>Now Loading...</center></td></tr>"); $(this).attr('disabled', 'disabled'); setTimeout(function(){ $.ajax({ url: "https://geoip-db.com/jsonp", jsonpCallback: "callback", dataType: "jsonp", success: function(location) { data = "<tr>" + "<td>"+location.country_name+"</td>" + "<td>"+location.latitude+"</td>" + "<td>"+location.longitude+"</td>" + "</tr>"; $('#result').html(data); } }); }, 2000); }); });