javascript get id value into variable
<p>I have used an api to get some information about someone who visits my page. The data is returned into a JSON format and I have used the .html function to set the content into some IDs like this: </p>

<pre><code>$.getJSON("http://ip-api.com/json/?callback=?", function (data) {
    $("#lat").html(data.lat);
    $("#lon").html(data.lon);
});
</code></pre>

<p>Using: </p>

<pre><code>&lt;p id="lat"&gt;&lt;/p&gt; 
&lt;p id="lon"&gt;&lt;/p&gt;
</code></pre>

<p>in my html body, I can see that the data has been set and is printed in my browser.</p>

<p>My question is how can I retrieve the data that is printed from the IDs into another, separate variable to continue to use/pass of to other functions ? I have tried using different functions like <code>getElementById()</code> etc. but none have worked.</p>