title: jQuery to output the user's city to their browser using the freegeoip.net API using AJAX and JSONP
body: <p>I have a question which am not sure I understand fully the question and the question says;</p>
  <blockquote>
  <p>Write Javascript or jQuery to output the user's city to their browser using the <a href="http://freegeoip.net/" rel="nofollow noreferrer">freegeoip.net</a> API using AJAX and JSONP.</p>
  <p>Hint: Use the endpoint <a href="http://freegeoip.net/json/?callback=parseResponse" rel="nofollow noreferrer">http://freegeoip.net/json/?callback=parseResponse</a></p>
  </blockquote>
  <p>I figured out the question says:  <em>use that API to get the current location and display the city in the browser</em> and this is what I have done on jsFiddle and am able to get <code>City</code>:</p>
  <p>jQuery</p>
  <pre><code>$.get(&quot;http://freegeoip.net/json/&quot;, function (response) {
      $(&quot;#address&quot;).html(&quot;City: &quot; + response.city);
      $(&quot;#details&quot;).html(JSON.stringify(response, null, 4));
  }, &quot;jsonp&quot;);
  </code></pre>
  <p>HTML</p>
  <pre><code>&lt;hr/&gt;
  &lt;div id=&quot;address&quot;&gt;&lt;/div&gt;
  &lt;hr/&gt;Full response: &lt;pre id=&quot;details&quot;&gt;&lt;/pre&gt;
  </code></pre>
  <p>Here is the thing, am not sure am doing what the question says. I will be glad if someone could shed more light into this.</p>