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