I am working with the themoviedb.org API to retrieve movie information. Below is the code I have implemented:
let req = new XMLHttpRequest();
req.open("GET", "http://api.themoviedb.org/2.1/Movie.search/en/json/XXX/immortals?callback=foobar", true);
req.send();
req.onreadystatechange=function() {
if (req.readyState==4 && req.status==200) {
console.log(req.responseText);
}
}
The response in my console looks like this:
foobar([{"score":null,"popularity":3,"translated":true,"adult":false,"language":"ru","original_name":"Immortals","name":"Immortals","alternative_name":"\"War of the Gods\"","movie_type":"movie","i".......}])
How can I extract the name
attribute from this response?
Updates:
I appreciate everyone's input, but credit goes to hippietrail for providing the solution.
eval(req.responseText)
For more information, refer to Filtering to specific nodes in JSON - use grep or map?