freegeoip 不再工作 [英] freegeoip doesn't work anymore

查看:30
本文介绍了freegeoip 不再工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个月前,我创建了一个代码,用于检测访问国并显示法定饮酒年龄.欧盟国家为 18,其他国家为 21.

A few months ago I created a code that detect a visitor country and display the legal drinking age. For country in EU is 18 and for other countries is 21.

我使用的是 freegeoip.

I'm using the freegeoip.

代码运行良好,但现在我发现它不再起作用了.

The code was working great, but now I noticed that doesn't work anymore.

    $.get("http://freegeoip.net/json/", function (response) {
    $("#ip").html("IP: " + response.ip);
    $("#country_code").html(response.country_code);
    if(response.country_code=='AL','AD','AT','BY','BE','BA','BG','HR','CY','CZ','DK','EE','FO','FI','FR','DE','GI','GR','HU','IS','IE','IT','LV','LI','LT','LU','MK','MT','MD','MC','NL','NO','PL','PT','RO','RU','SM','RS','SK','SI','ES','SE','CH','UA','VA','RS','IM','RS','ME') {
        $(".age").html("18");
    } else {
        $(".age").html("21");
    }
}, "jsonp");

我在这里显示年龄:

<span>ARE YOU</span> OVER <span class="age"></span>?

我认为问题出在 freegeoip 上,但我无法解决.

I assume that the problem is in freegeoip but I can't fix it.

推荐答案

我刚刚找到了问题的答案.我注意到 freegeoip.net 网站无法使用,所以我更改了服务.

I just found an answer for the problem. I noticed that the freegeoip.net website doesn't work so I changed the service.

我用 http://getcitydetails.geobytes.com/GetCityDetails?callback=?

并添加 <script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesLocationCode,GeobytesCode,GeobytesInternet,GeobytesFqcn"></script>

现在代码又可以工作了.

Now the code works again.

这篇关于freegeoip 不再工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆