title: Getting info out of jQuery and assigning it to a variable for using it in JavaScript
body: <p>I am having trouble getting country code out of jQuery.</p>
  <p>I can get the users information using the IP. I want to get country code out of it and assign it to a variable so I can use it inside a function.</p>
  <p>Here is the code I am using;</p>
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js&quot;&gt;&lt;/script&gt;
  
    &lt;script&gt;
      $.get(&quot;http://ipinfo.io&quot;, function(response) {
        $(&quot;#ip&quot;).html(&quot;IP: &quot; + response.ip);
        $(&quot;#address&quot;).html(&quot;Location: &quot; + response.city + &quot;, &quot; + response.region);
        $(&quot;#details&quot;).html(JSON.stringify(response, null, 4));
      }, &quot;jsonp&quot;);
    &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;h3&gt;Client side IP geolocation using &lt;a href=&quot;http://ipinfo.io&quot;&gt;ipinfo.io&lt;/a&gt;&lt;/h3&gt;
  
    &lt;hr/&gt;
    &lt;div id=&quot;ip&quot;&gt;&lt;/div&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;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p>Here I want to use the country code and assign to a variable.</p>