index.html 2.6KB

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