Command Palette

Search for a command to run...

Hectal
Phase 12: AI That Runs in the Browser
AI Frontend · Exercise 2 of 5 PreviousNext
Intermediate

Show Download Progress

Clicking #download fetches a pretend model file. While it downloads, keep #bar (a <progress> with max="100") and #pct (text such as 40%) up to date from the bytes received and the Content-Length header. When it ends, put Ready in #status.

Clicking #download-bad fetches a file that does not exist. Show Could not download the model (HTTP 404) in #error and do not touch the bar.

What Check tests

  1. Before any click, #pct says 0%
  2. While downloading, #bar is above 0 and below 100
  3. At the end #bar is 100, #pct says 100% and #status says Ready
  4. A missing file shows the error and no Ready

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.