Get IP & Geolocation Info Using jQuery - geo-fetch.js
File Size: | 3.5 KB |
---|---|
Views Total: | 2280 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
geo-fetch.js is a tiny jQuery plugin that gets visitor's IP and Geolocation information by fetching data from Cloudflare Trace and Freegeoip.app via AJAX requests.
Geolocation Info:
- City
- Country Code
- Country Name
- IP
- Latitude
- Longitude
- Metro Code
- Region Code
- Region Name
- Timezone
- Zip Code
How to use it:
1. Insert the main JavaScript geo-fetch.js after loading jQuery library.
<script src="/path/to/cdn/jquery.min.js"></script> <script src="/path/to/geo-fetch.js"></script>
2. Get your visitor's IP and Geolocation information.
console.log(userIPInfo);
3. This will return an object containing Geolocation info based on IP.
address. city: "" country_code: "US" country_name: "" ip: "xxx.xxx.xxx.xxx" latitude: 37.751 longitude: -97.822 metro_code: 0 region_code: "" region_name: "" time_zone: "America/Chicago" zip_code: ""
This awesome jQuery plugin is developed by rafaelatantya. For more Advanced Usages, please check the demo page or visit the official website.