index.js 632B

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