我有这个脚本
$.get("http://ipinfo.io", function (response) {
$("#ip").html("" + response.ip);
$("#address").html("Location: " + response.city + ", " + response.region);
$("#details").html(JSON.stringify(response, null, 4));
}, "jsonp");
$.ajax({
url: "http://ipinfo.io/json",
success: function(response) {
var pais = (response.country);
if(pais=='BR') {
//do something //
}
},
dataType: 'json',
statusCode: {
429: function() {
alert( "Number of tries exceeded" );
}
}
});
它应该获取用户的IP,它可以在localhost上运行但是当我将它上传到服务器时它无法正常工作.. 有什么建议吗?