Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140762

Display all values from JavaStript result

$
0
0

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.


Viewing all articles
Browse latest Browse all 140762

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>