ajax
ajax copied to clipboard
Add support for cancel event in file selection input
This PR adds the ability to listen for the cancel event. When the cancel event is fired, the promise is rejected.
Currently, if the user cancels the upload, the promise is always in pending state, which should not make sense.
I am using this great library to implement image upload functionality. Currently I need to listen to the user's cancel action. I'm sure others will have this need as well.
Modern browsers already implement the Input's Cancel event, so it only takes a small amount of code to implement this functionality.
references:
- https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/cancel_event
- https://caniuse.com/mdn-api_htmlinputelement_cancel_event
fixed: #50
that would be amazing to add this