So I'm trying to use a free service to get the visitor's location and redirect them to the proper page. The problem is that these free services don't always work; freegeoip has a limit of 10000 requests per day and I'm not sure about telize.
What I want to do is to load another json if the initial one fails.
To be honest I don't know if it is possible my way. I apreciate any other ideas or scripts, the main idea is just to get the visitor's location and point them to the right page, using javascript. I'm on Blogger, by the way, so not so many options available.
Regards.

<script>
jQuery.ajax({
  dataType: "json",
  url: 'http://www.telize.coom/geoip?callback=?',
  cache: true,
  success: function(location) {
if (location.country_code == 'ID') { 
window.top.location.href = 'http://id.example.com';
}
else if (location.country_code == 'US') { 
window.top.location.href = 'http://en.example.com';
}
},
error: function(location) {
jQuery.getJSON('http://freegeoip.net/json/', function(location) {
if (location.country_code == 'ID') { 
window.top.location.href = 'http://id.example.com';
}
else if (location.country_code == 'US') { 
window.top.location.href = 'http://en.example.com';
}
})
}
</script>

This may not be the answer your looking for but i would fire off both requests and use the first one that responded correctly.

Member Avatar
[NOPE]FOREVER

there is no such thing as an ajax.jquery function

commented: gfh +0
commented: hyepr active +0