Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://ipinfodb.com/ip_location_api.php" rel="nofollow noreferrer">IP location XML API</a> requires some query strings like <code>&amp;format=json&amp;callback=?</code> additional to ip address in order to get json.</p> <p>Then you get json like this:</p> <pre><code>{ "statusCode": "OK", "statusMessage": "", "ipAddress": "175.108.204.0", "countryCode": "JP", "countryName": "JAPAN", "regionName": "TOKYO", "cityName": "TOKYO", "zipCode": "214-002", "latitude": "35.6149", "longitude": "139.581", "timeZone": "+09:00" } </code></pre> <p>Here is a sample code (thanks to @iveoak for good template):</p> <pre><code>function getLocFromIP(IP){ //(js code to use ipinfodb API to get valid JSON response) var url = 'http://api.ipinfodb.com/v3/ip-city/?key=&lt;your_api_key&gt;&amp;ip=' + ip + '&amp;format=json&amp;callback=?'; var response = $.getJSON(url); // using jQuery //(js code using JSON.parse to parse the received JSON response) response.then(function (location) { var info = '&lt;ul&gt;'; for (var key in location) { info += '&lt;li&gt;' + key + ': ' + location[key] + '&lt;/li&gt;'; } info += '&lt;/ul&gt;'; }); //(js code to get whatever you want as the result) return result; } </code></pre> <p>If you do not use jQuery, see <a href="https://stackoverflow.com/questions/9838812/how-can-i-open-a-json-file-in-javascript-without-jquery">How can I open a JSON file in JavaScript without jQuery?</a>.</p> <p>Sample (using jQuery): <a href="http://jsfiddle.net/tokkonoPapa/tevB4/" rel="nofollow noreferrer">http://jsfiddle.net/tokkonoPapa/tevB4/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload