最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - geo_ip.js is not working - Stack Overflow

programmeradmin7浏览0评论

I am using ".js" for multilingual site support but this link is throwing 404 error.

Here is the error

Failed to load resource: the server responded with a status of 404 (Not Found)
www.globalenglish/:913 Uncaught ReferenceError: geoip_country_code is not defined
chrome-extension://gllmlkidgbagkcikijiljllpdloelocn/contentscript.js:1849 www.globalenglish
getuid:1 GET …I%252bJLufjW0EE6tV4BHMF43u8yA9qpnPTK8G7tGxJuiy5ReJz%252fscH55wHNbnsJU%253d 403 (Forbidden)

I checked the site here for new link, this link throws 401 error.

I also checked new API here but this also did not work for me. JS Link works but geoip_country_code() is undefined

How to make it work again !!!! Here is fiddle

Thanks

I am using "http://j.maxmind./app/geoip.js" for multilingual site support but this link is throwing 404 error.

Here is the error

Failed to load resource: the server responded with a status of 404 (Not Found)
www.globalenglish./:913 Uncaught ReferenceError: geoip_country_code is not defined
chrome-extension://gllmlkidgbagkcikijiljllpdloelocn/contentscript.js:1849 www.globalenglish.
getuid:1 GET https://api.bizographics./v2/getuid?api_key=422935bcbfc445d59f10758c288c…I%252bJLufjW0EE6tV4BHMF43u8yA9qpnPTK8G7tGxJuiy5ReJz%252fscH55wHNbnsJU%253d 403 (Forbidden)

I checked the site here for new link, this link throws 401 error.

I also checked new API here but this also did not work for me. JS Link works but geoip_country_code() is undefined

How to make it work again !!!! Here is fiddle

Thanks

Share Improve this question asked Mar 4, 2015 at 10:51 HiteshHitesh 4,29812 gold badges52 silver badges83 bronze badges 2
  • 1 It seems that this link is not available anymore, and there is an other version of geoip (2.1) available at js.maxmind./js/apis/geoip2/v2.1/geoip2.js. – Halim Qarroum Commented Mar 4, 2015 at 10:55
  • it throws error geoip_country_code() is undefined – Hitesh Commented Mar 4, 2015 at 12:51
Add a ment  | 

3 Answers 3

Reset to default 5

Unfortunately, Maxmind doesn't provide a geoip api through

http://j.maxmind./app/geoip.js

anymore. Although it provides another api as

http://js.maxmind./js/apis/geoip2/v2.1/geoip2.js

However it requires a domain registration etc. according to Maxmind's website. The link below is a clone of the old api and valid for around one year now.

http://geoapi123.appspot./

I've just used this for one of my projects in development stage for a very quick solution. But I strongly suggest you to update your code according to a trustworthy service again.

A working jsfiddle to show how things could play on here; which shows this chunk of code:

$.ajax( {
            type: 'GET',
            url: '//geoapi123.appspot./',
            dataType: 'script',
            cache: true,
            success: function() {
                var geo = geoip_country_code() + '|' + geoip_region_name() + '|' + geoip_city() + '|' + geoip_latitude() + '|' + geoip_longitude();
                $('#results').html(geo);
            }
        });

UPDATE: I realised this answer is still getting attraction. Please be aware it has been years since I wrote this one. The URL I shared does not seem to be working anymore. Also there are much better approaches to handle the problem now.

Actually, there is a message in the console you might have missed :

Users of the GeoIP2 JavaScript API must register their domains at https://www.maxmind./en/javascript_domains

The loading of the library failed because a request is issued to the js.maxmind. domain with your current hostname (fiddle.jshell in your case) as the referrer to ensure that the client was actually making a request from an authorized hostname.

hey guys i'm using This script but i don't know why HTTPS doesn't work when i try to redirect .. it only work With HTTPS

    $.ajax({
        url: "http://api.petabyet./geoip",
        success: function(data) {
            switch (data.country_code) {
                case 'DE':
                    window.location.href = "https://google./de";
                    break;
               
                
            }
        }
    })

</script>
发布评论

评论列表(0)

  1. 暂无评论