123456789101112131415161718192021222324252627
  1. const request = new XMLHttpRequest();
  2. var movies;
  3. var output = "";
  4. request.open('GET', 'https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD');
  5. request.onreadystatechange = function(){
  6. if((request.status==200) && (request.readyState==4)){
  7. // console.log(request.responseText);
  8. movies = JSON.parse(request.responseText);
  9. for (i = 0; i < movies.data.length; i++) {
  10. if (movies.data[i][10] == "Golden Gate Bridge")
  11. output += "Movie Title: " + movies.data[i][8] + "<br/>"
  12. + "Release Year: " + movies.data[i][9] + "<br/>"
  13. + "Production Company: " + movies.data[i][12] + "<br/>"
  14. + "<br/>";
  15. }
  16. document.getElementById('result').innerHTML += output;
  17. }
  18. }
  19. request.send();