-2
I just modified an example of HTML with Json but it is an array type and apparently what I want to use is an object, I believe this is the problem. json contains this information:
{"riotschmick":{"id":585897,"name":"Riotschmick","profileIconId":956,"summonerLevel":30,"revisionDate":1449128440000}}
I believe there’s something missing in the code to work Here is the example:
<!DOCTYPE html>
<html>
<body>
<h1>Meu Projeto</h1>
<div id="id01"></div>
<div id="id02"></div>
<script>
var xmlhttp = new XMLHttpRequest();
var url = "https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/RiotSchmick?api_key=a15c56d1-fdd7-4da2-ad9c-0f1a6585ac1b";
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
myFunction(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(response) {
var arr = JSON.parse(response);
var out = "<h1>";
out += arr.id + arr.name + arr.summonerLevel;
out += "</h1>";
document.getElementById("id01").innerHTML = out;
}
</script>
</body>
</html>
What do you mean, "type of JSON"? I read your question and did not understand.
– felipsmartins
json files have a unique structure, if you change it is no longer
json
. Explain it better, talk about another file.json
with data other than the current ?– Edilson
I’ve found thank you all!
– Johnner