GetMovies.js 654B

12345678910111213141516171819202122
  1. var xhr = new XMLHttpRequest();
  2. xhr.open("GET","https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD");
  3. xhr.send();
  4. xhr.addEventListener("readystatechange", processRequest, false);
  5. xhr.onreadystatechange = processRequest;
  6. function processRequest()
  7. {
  8. if (xhr.readyState == 4 && xhr.status == 200)
  9. {
  10. response = JSON.parse(xhr.responseText);
  11. for (i=0; i<1622; i++)
  12. {
  13. if(response.data[i][10] == "Golden Gate Bridge")
  14. document.getElementById("result").innerHTML += "Title: "+(response.data[i][8]+"<br>"+"Production year: "+response.data[i][9]+"<br>"+" Location: "+response.data[i][10]+"<br>"+"<br>");
  15. }
  16. }
  17. }