I have this function. With xhr.response I get my json values. Question: how do I attach these JSON values to my HTML labels? Thank you.
Unrelevant question: Does anyone know of a good website where beginning JSON concepts are compactly summarized?
For example country to the label country.
function initPage(){
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://ip-api.com/json", false);
xhr.send();
console.log(xhr.status);
console.log(xhr.statusText);
console.log(xhr);
console.log(xhr.response);
}
JSON Output: Visit http://ip-api.com/json
Desired HTML:
<label id="landcode"></label>
<label id="country"></label>
<label id="regio"></label>
<label id="city"></label>
<label id="postcode"></label>
<label id="latitude"></label>
<label id="longitude"></label>
<label id="ip"></label>