Get Programming with JavaScript - Listing 20.02

Listing 20.02 - Parsing JSON text to obtain a JavaScript object

var xhr = new XMLHttpRequest(); var url = "http://output.jsbin.com/qiwizo.json"; xhr.addEventListener("load", function () { var data = JSON.parse(xhr.responseText); console.log(data); }); xhr.open("GET", url); xhr.send();