I have this Javascript:
function sendRequest_for_Get_Popular() {
movies_ArrayDataModel.clear();
var xhr = new XMLHttpRequest();
var url = "http://api.themoviedb.org/3/movie/popular?api_key="
+ config.API_KEY + "&language=en-US&page=1";
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
var lenght = response.results.length;
for (var i = 0; i < lenght; i++) {
var results = response.results[i];
var image = "http://image.tmdb.org/t/p/w200/";
// ========== ========== ==========
test.text = results.title;
// ========== ========== ==========
}
}
}
};
xhr.open("GET", url, true);
xhr.send();
}
And this JSON file:
{
"page": 1,
"total_results": 2,
"total_pages": 1,
"results": [
{
"id": 475557,
"title": "Joker",
},
{
"id": 420809,
"title": "Maleficent: Mistress of Evil",
}
]
}
I need to write all "title"
values in the "test"
field.
For example, in this format: "Joker, Maleficent: Mistress of Evil"
Now I only get the value of the last "title"
.
Example: "Maleficent: Mistress of Evil"
Thank you.