12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <link href="./css/style.css" type="text/css" rel="stylesheet">
  6. <title>Import Local JSON Data | Zipcode Wilmington</title>
  7. </head>
  8. <body>
  9. <header class="main-header group">
  10. <div class="title"><h1>Zipcode Wilmington<br>Javascript Lab - Fall 2015</h1></div>
  11. <div class="lesson-link"><img src="./images/logos/js_logo.png" alt="Javascript"/></div>
  12. <div class="zip-link"><img src="./images/logos/zip_logo.jpg" alt="Zipcode Wilmington"/></div>
  13. </header>
  14. <article>
  15. <h1>Instructions</h1>
  16. <p>Us the <code>XMLHttpRequest()</code> to receive the remote json feed from the following website<br>
  17. https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD
  18. </p>
  19. <p>The json feed list movies made in San Francisco</p>
  20. <p>Write the following info for each movie to the webpage:
  21. <ul>
  22. <li>movie title</li>
  23. <li>release year</li>
  24. <li>production company</li>
  25. </ul>
  26. </p>
  27. <p>Only list movies that were made at the Golden Gate Bridge</p>
  28. <p>Use <code>document.getElementById('result').innerHTML += <i>your_output</i>;</code> to write the movie's info to
  29. the page.</p>
  30. <p>Append <code>"&ltbr&gt"</code> to output code to create a new line</p>
  31. </article>
  32. <script>
  33. var xhttp = new XMLHttpRequest();
  34. var url = "https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD";
  35. xhttp.onreadystatechange = function () {
  36. if (this.readyState === 4 && this.status === 200) {
  37. var object = this.responseText;
  38. var object1 = JSON.parse(object);
  39. var object2 = object1.data;
  40. for (let i = 0; i < object2.length; i++) {
  41. var movies = object2[i];
  42. if (movies[10] === "Golden Gate Bridge") {
  43. document.getElementById("result").innerHTML += movies[9] + "<br>";
  44. document.getElementById("result").innerHTML += movies[8] + "<br>";
  45. document.getElementById("result").innerHTML += movies[12] + "<br>";
  46. }
  47. }
  48. }
  49. };
  50. xhttp.open("GET", url, true);
  51. xhttp.send();
  52. </script>
  53. <section>
  54. <h1>Movie Information</h1>
  55. <div id="result"></div>
  56. </section>
  57. </body>
  58. </html>