Connor Dunnigan 7 лет назад
Родитель
Сommit
e5fed5f0e5
2 измененных файлов: 18 добавлений и 1 удалений
  1. 2
    1
      index.html
  2. 16
    0
      sanFranMovies.js

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

@@ -33,10 +33,11 @@
33 33
         <p>Use <code>document.getElementById('result').innerHTML += <i>your_output</i>;</code> to write the movie's info to the page.</p>
34 34
         <p>Append <code>"&ltbr&gt"</code> to output code to create a new line</p>
35 35
     </article>
36
-
36
+   
37 37
     <section>
38 38
     	<h1>Movie Information</h1>
39 39
     	<div id="result"></div>
40 40
     </section>
41
+     <script type="text/Javascript" src="sanFranMovies.js"> </script>
41 42
 </body>
42 43
 </html>

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

@@ -0,0 +1,16 @@
1
+var xhr = new XMLHttpRequest();
2
+xhr.open('GET','https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD');
3
+xhr.onreadystatechange = function(){
4
+	if((xhr.status===200) && (xhr.readyState===4)){
5
+		let movieData = JSON.parse(xhr.responseText);
6
+		let movies = movieData.data;
7
+		for(let i = 0; i < movies.length; i++){
8
+			let currentMovie = movies[i];
9
+			if(currentMovie[10]=='Golden Gate Bridge'){
10
+				document.getElementById('result').innerHTML += currentMovie[8] +
11
+					 ' - ' + currentMovie[9] + ' - ' + currentMovie[12] + '<br>';
12
+			}
13
+		}
14
+	}
15
+}
16
+xhr.send();