#31 jaejoson JSON-Lab2

Aberto
jaejoson quer mesclar 1 commits de jaejoson/JSON-Lab-2:master em master
2 arquivos alterados com 20 adições e 1 exclusões
  1. 2
    1
      index.html
  2. 18
    0
      javaScript.js

+ 2
- 1
index.html Ver arquivo

@@ -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 Ver arquivo

@@ -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
+