I'm trying to get the region_code from freegeoip using...
$.getJSON('http://freegeoip.net/json/', function(location) {
console.log(location);
It returns an object as follows...
city: "Medford"
country_code: "US"
country_name: "United States"
ip: "69.142.34.172"
latitude: 39.8741
longitude: -74.809
metro_code: 504
region_code: "NJ"
region_name: "New Jersey"
time_zone: "America/New_York"
zip_code: "08055"
I need to get the region_code and if it is "NJ", do a redirect to a different URL?
I tried this...
var t = JSON.parse('{"city": "", "country_code": "", "country_name": "", "ip": "", "latitude": "", "longitude": "", "metro_code": "", "region_code": "", "region_name": "", "time_zone": "", "zip_code": ""}'); console.log(t['region_code']);
But saw nothing in the console.