-4
I’m making a requisicao to get this JSON, and would like to know how to assemble a li using this request
var url = "data.json";
var httpRequest = new XMLHttpRequest();
httpRequest.open("GET", url);
httpRequest.responseType = "json";
httpRequest.addEventListener("readystatechange", function () {
if (httpRequest.readyState == 4){
if (httpRequest.status == 200){
console.log(httpRequest.response);
console.log(httpRequest.response.headDocument);
console.log(httpRequest.response.headDocument.authors);
console.log(httpRequest.response.headDocument.content);
} else {
console.log("fiz algo errado xD")
}
}
});
httpRequest.send();
You can use the Handlebars to build a template, then combine the template to json
– Tobias Mesquita
could give me an example using my code above?
– Bruno Bafilli
Bruno, check the formatting and content of your question. It’s hard to understand what you meant.
– Pablo Almeida
It’s gotten a little better, Bruno, but there’s still an example of in and out. Show what your JSON looks like and how you want your JSON to look like.
– Pablo Almeida
@Pablo, he mentioned the JSON source in another question... follow the example: https://jsfiddle.net/TobyMosque/xtk52m1o/
– Tobias Mesquita
@Tobymosque Blz, but he still has to explain how he wants this read
– Pablo Almeida
Which part of json will be used to build the list? It’s huge! headDocument.content ?
– Filipe Moraes
@Felipemoraes, so we are asking for a template of what will be generated.
– Tobias Mesquita
That
httpRequest.open("GET", url);
shouldn’t be thishttpRequest.open("GET", url, true);
in order to use thereadystatechange
?– Guilherme Nascimento
Friend I would vote right away to close the question a asked that it remains obscure after 2 days, not this clear enough where is the problem, as I just came back from a penalty for voting too fast I will vote to leave open until you rephrase the question ok.
– SneepS NinjA