#27 js file

Открыто
jbedolla40 хочет смерджить 1 коммит(ов) из jbedolla40/JSON-Lab-2:master в master
2 измененных файлов: 29 добавлений и 1 удалений
  1. 3
    1
      index.html
  2. 26
    0
      index.js

+ 3
- 1
index.html Просмотреть файл

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

+ 26
- 0
index.js Просмотреть файл

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