Bladeren bron

{done this one! - need to review again}

Jacqueline Joson 5 jaren geleden
bovenliggende
commit
073f2e7d7e
2 gewijzigde bestanden met toevoegingen van 20 en 1 verwijderingen
  1. 2
    1
      index.html
  2. 18
    0
      javaScript.js

+ 2
- 1
index.html Bestand weergeven

@@ -36,7 +36,8 @@
36 36
 
37 37
     <section>
38 38
     	<h1>Movie Information</h1>
39
-    	<div id="result"></div>
39
+        <div id="result"></div>
40
+        <script src = "javaScript.js" type = "text/javascript"></script>
40 41
     </section>
41 42
 </body>
42 43
 </html>

+ 18
- 0
javaScript.js Bestand weergeven

@@ -0,0 +1,18 @@
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
+
6
+        var jsonInfo = JSON.parse(httpRequest.responseText).data;
7
+
8
+        for (var i = 0; i < jsonInfo.length; i++) {
9
+            if (jsonInfo[i][10] == "Golden Gate Bridge") {
10
+                document.getElementById('result').innerHTML += (jsonInfo[i][8] + " (" + jsonInfo[i][9] 
11
+                + ") <br> Produced by " + jsonInfo[i][12] + "<br><br>");
12
+            }
13
+        }
14
+    }
15
+};
16
+
17
+httpRequest.send();
18
+