Homework 8: More AJAX
- Due Oct 1, 2024 by 9:30am
- Points 1
- Submitting a website url
- Available after Sep 26, 2024 at 9:30am
This is a from scratch homework. You're going to have three files:
- quotes.csv—a CSV file containing one famous quote per line; you should download this from here Links to an external site.; note that it has a header.
- quotes.php—a PHP file that will return a list of n randomly selected quotes from quotes.csv as a JSON string; extracts the value of n from GET parameters.
- quotes.html—an HTML file that has a number input box and a "Get quotes" button; when the button is pressed, as long as the number in the input box is non-negative, it should make an AJAX request to quotes.php to get the given number of quotes, then display them below, nicely formatted; each click on "Get quotes" should remove any existing quotes from the page.
You should find these PHP functions helpful:
- file() Links to an external site.
- str_getcsv() Links to an external site.
- random_int() Links to an external site.
As usual, feel free to work with others (just make note in your code who you worked with), and you may use generative AI to assist you (again, cite anywhere you use it).
Commit your files to your CSC302 git repository in the folder homework/hw8
. Push to GitHub and submit a link to the GitHub folder to this assignment.