Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSS/HTML Question: So, I am trying use a JSON array from a URL, and convert it into an array on brackets, and use the array

CSS/HTML Question:

So, I am trying use a JSON array from a URL, and convert it into an array on brackets, and use the array that I gathered from online in my html. I know I am close, but there is something I am doing wrong, and my JS file isn't working. I can't seem to figure out what my mistake is, so can you guys look at my JS and HTML file and show me how I can fix this issue.

Thank you.

image text in transcribed

image text in transcribed

1 /1 converts a json file from a url to an array var xmlhttp new XMLHttpRequest(); 3 var url"http://movieroulette.net/movieArray.json"; 4 5 xmlhttp . onreadystatechange = function() { 6 if (xmlhttp. readyState 4 && xmlhttp. status == 200) { var theArray JSON . parse(xmlhttp. responseText); getRandomMovie(theArray); 9 10 11 xmlhttp.open ("GET", url, true); 12 xmlhttp.send ); 16 // Picks a movie from the array. 17 function getRandomMovie(theArray) 18 19 20 21 var randNum var htmlArray"" var imgArray "I randNum Math.floor (Math.random() arr.length); if (randNum 0) if (randNum > arr. length) 23 24 25 26 27 28 29 30 31 32 randNum: randNumarr.length 1; htmlArray +- "Want to Learn More? CLICK ingArray += ; HERE!"; 34 35 36 37 38 39 40 document.getElementById('' a r rName").innerHTML = arr[randNum].name ; document.getElementById ("arrGenre").innerHTMLarr[randNum].genre; document.getElementById("arrYear").innerHTMLarr[randNum].year; document.getElementById('' a r rRating").innerHTML arr[randNum].rating; document.getElementById('' a r rRuntme").innerHTML arr [randNum].runtime ; document.getElementById("arrURL").innerHTML htmlArray; document.getElementById("arrTmg"). nnerHTML mgArray; 42 1 2 head> Movie Roulette @import url('https://fonts.googleapis.com/css?family Concert+One')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

4. How is culture a contested site?

Answered: 1 week ago