|
|
@@ -39,4 +39,36 @@
|
|
39
|
39
|
<div id="result"></div>
|
|
40
|
40
|
</section>
|
|
41
|
41
|
</body>
|
|
|
42
|
+
|
|
|
43
|
+<script type="text/javascript">
|
|
|
44
|
+ var get = function()
|
|
|
45
|
+ {
|
|
|
46
|
+ var movies;
|
|
|
47
|
+ //create a new XML object to send the request.
|
|
|
48
|
+ //mosSystem prrevents cross orgina requests error.
|
|
|
49
|
+ var http = new XMLHttpRequest({mozSystem: true});
|
|
|
50
|
+ http.onreadystatechange = function() {
|
|
|
51
|
+ if(http.readyState === 4 && http.status === 200) {
|
|
|
52
|
+ movies = JSON.parse(http.responseText);
|
|
|
53
|
+ //console.log(movies);
|
|
|
54
|
+ for(var i = 0; i < movies.data.length; i ++){
|
|
|
55
|
+ var movie = movies.data[i];
|
|
|
56
|
+ if(movie[10] == "Golden Gate Bridge"){
|
|
|
57
|
+ document.getElementById('result').innerHTML +=(movie[8] + " " + movie[9] + " " + movie[12]) + "<br>";
|
|
|
58
|
+ }
|
|
|
59
|
+ }
|
|
|
60
|
+ }
|
|
|
61
|
+ }
|
|
|
62
|
+ //log the input so I can confirm this in the text file/
|
|
|
63
|
+ //open a new post request to be sent to the host over port 3000
|
|
|
64
|
+ http.open("GET", "https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD", true);
|
|
|
65
|
+ //send the request as an application.
|
|
|
66
|
+ http.setRequestHeader("Content-Type", "text/plain");
|
|
|
67
|
+ //send the request
|
|
|
68
|
+ http.send();
|
|
|
69
|
+ return movies;
|
|
|
70
|
+ }
|
|
|
71
|
+
|
|
|
72
|
+ get();
|
|
|
73
|
+</script>
|
|
42
|
74
|
</html>
|