So i'm trying to parse this json with javascript and it reads it from the webpage correctly however it just freezes when reaching the JSON.parse.
Here's what the webpage outputs:
{
Players: 18,
maxPlayers: 32,
Map: "jb_summer_redux_v3"
}
Here's what the full code is:
var xhr = new XMLHttpRequest();
var url = "http://in.nickparksdev.com/info.php";
document.write("Loading....");
xhr.open("GET", url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
document.write(xhr.responseText);
var jsonResponse = JSON.parse(xhr.responseText);
document.write("Test: " + jsonResponse.Players);
}
}
xhr.send();
Here's what that document.write(xhr.responseText); outputs:
{"Players":19,"maxPlayers":32,"Map":"jb_summer_redux_v3"}
Any help on this would be great :)
Players,maxPlayers, andMap? The first part of your question says it doesn't, but thexhr.responseTextshows that it does.console.log()instead ofdocument.write()?