freegeoip不再起作用了 [英] freegeoip doesn't work anymore

查看:142
本文介绍了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:// freegeoip.net/json / http://getcitydetails.geobytes.com/GetCityDetails?callback=?

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

现在代码再次运作。

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

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