javaScript.js 676B

12345678910111213141516171819
  1. var httpRequest = new XMLHttpRequest();
  2. httpRequest.open("GET", "https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD", true);
  3. httpRequest.onreadystatechange = function() {
  4. if ((httpRequest.readyState == 4) && (httpRequest.status == 200)) {
  5. var jsonInfo = JSON.parse(httpRequest.responseText).data;
  6. for (var i = 0; i < jsonInfo.length; i++) {
  7. if (jsonInfo[i][10] == "Golden Gate Bridge") {
  8. document.getElementById('result').innerHTML += (jsonInfo[i][8] + " (" + jsonInfo[i][9]
  9. + ") <br> Produced by " + jsonInfo[i][12] + "<br><br>");
  10. }
  11. }
  12. }
  13. };
  14. httpRequest.send();