#32 Completed!

Open
pchai7 wants to merge 1 commits from pchai7/JSON-Lab-2:master into master
1 changed files with 28 additions and 2 deletions
  1. 28
    2
      index.html

+ 28
- 2
index.html View File

@@ -36,7 +36,33 @@
36 36
 
37 37
     <section>
38 38
     	<h1>Movie Information</h1>
39
-    	<div id="result"></div>
39
+
40
+    	<div id="result">
41
+      <script>
42
+      let httpClient=function(){
43
+      let movies;
44
+      let url='https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD';
45
+      let HRequest = new XMLHttpRequest();
46
+      HRequest.onreadystatechange =function(){
47
+          if(HRequest.readyState ==4 && HRequest.status == 200){
48
+              movies = JSON.parse(HRequest.responseText);
49
+              for(var i = 0; i < movies.data.length;i++){
50
+                  let movie= movies.data[i];
51
+                  if(movie[10]=="Golden Gate Bridge"){
52
+                      document.getElementById('result').innerHTML +=(movie[8]+ " "+movie[9]+" "+movie[12])  + "<br>";
53
+                  }
54
+              }
55
+          }
56
+      }
57
+      HRequest.open("GET",url,true);
58
+      HRequest.setRequestHeader("Content-Type","text/plain");
59
+      HRequest.send();
60
+      return movies;}
61
+      httpClient();
62
+
63
+      </script>
64
+      </div>
65
+
40 66
     </section>
41 67
 </body>
42
-</html>
68
+</html>