Skip to content

Conversation

teoli2003
Copy link
Contributor

Description

Document XMLHttpRequestUpload and its events

Motivation

openwebdocs/project#152

@github-actions github-actions bot added the Content:WebAPI Web API docs label Mar 27, 2023
Copy link
Contributor

@dawei-wang dawei-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add missing word

@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs Content:HTTP HTTP docs Content:JS JavaScript docs Content:Learn Learning area docs Content:Other Any docs not covered by another "Content:" label Content:WebExt WebExtensions docs labels Mar 30, 2023
@teoli2003 teoli2003 force-pushed the XMLHttpRequestUpload branch from 9d6cfe0 to 7318754 Compare March 30, 2023 12:10
@github-actions github-actions bot removed Content:WebExt WebExtensions docs Content:Learn Learning area docs Content:JS JavaScript docs Content:CSS Cascading Style Sheets docs Content:Other Any docs not covered by another "Content:" label Content:HTTP HTTP docs labels Mar 30, 2023
@teoli2003 teoli2003 marked this pull request as ready for review March 30, 2023 12:17
@teoli2003 teoli2003 requested a review from a team as a code owner March 30, 2023 12:17
@teoli2003 teoli2003 requested review from Elchi3 and removed request for a team March 30, 2023 12:17
@Elchi3
Copy link
Member

Elchi3 commented Mar 31, 2023

First impression: Looks great! Do we want to repeat the (rich) example on all sub pages, though?

@teoli2003
Copy link
Contributor Author

First impression: Looks great! Do we want to repeat the (rich) example on all sub pages, though?

I was unsure. i can keep only the js with some of the events?

@Elchi3
Copy link
Member

Elchi3 commented Mar 31, 2023

First impression: Looks great! Do we want to repeat the (rich) example on all sub pages, though?

I was unsure. i can keep only the js with some of the events?

I think we often put snippets. Maybe something like this for the loadend page:

Examples

Using the loadend event

You can use the loaded event hide the progress bar when an upload finished. For a complete code example that uploads a file, see the main XHR upload page.

xhr.upload.addEventListener("loadend", (event) => {
  progressBar.classList.remove("visible");
  if (event.loaded !== 0) {
    log.textContent = "Upload finished.";
  }
  abortButton.disabled = true;
});

Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits. I think this looks good otherwise. It is mostly analog to XHR, I believe.

@Elchi3 Elchi3 merged commit 74cf7a1 into mdn:main Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants