我有一个网站,检查用户的IP,如果它从CA显示一条消息。
我正在使用JQuery检查用户的IP,代码在http://jquery-howto.blogspot.in/2009/04/get-geographical-location-geolocation.html
我已经在我的网站上实现了代码
我的问题是:
如何检查代码是否正常工作?因为我不在加州
发布于 2012-04-04 12:09:21
他们在那里给出的示例代码确实返回了状态。请注意,它们给出了一个新的URL:
// Utilize the JSONP API
$.getJSON('http://www.geoplugin.net/json.gp?jsoncallback=?', function(data){
var region = data['geoplugin_region'];
var country = data['geoplugin_countryCode'];
if(country == 'US' && region == 'CA')
{
console.log("In CA");
}
else
{
console.log("In " + region + ", " + country);
}
});这并不是您可以通过任何方式使用的唯一API。
Demo
https://stackoverflow.com/questions/10004745
复制相似问题