Get the location from an IP Address in Javascript

How to get the location from an IP Address in Javascript and JQuery.

One of ipdata's most useful features is that if you use it client-side with Javascript you don't have to pass in the user's IP address. We will automatically get the user's IP Address, geolocate it and return the geolocation data to you client-side.

An example request in JQuery

$.get("<<apiKey>>", function(response) {
}, "jsonp");

A simple call like above without passing in any parameters other than the API key will give you the location of the user currently on the page with the above code embedded.

Pure Javascript

var request = new XMLHttpRequest();'GET', '<<apiKey>>');

request.setRequestHeader('Accept', 'application/json');

request.onreadystatechange = function () {
  if (this.readyState === 4) {