I have a page that allows the user to download a dynamically-generated file. It takes a long time to generate, so I'd like to show a "waiting" indicator. The problem is, I can't figure out how to detect when the browser has received the file so that I can hide the indicator.
I'm requesting a hidd...
@Shad Oh, it's super simple. Use JS to send an async request to a C# end-point that generates the file and stores it temporarily. While the async request is not done, you can show the spinner. Once it's done, JS-side can receives the temporary id of the file, and can then request it.
[Captain Obvious] Show spinner, Fire off a request for the file, (wait), on request completion: hide the spinner, then request the completed file linked in the response
@Squirrelkiller no, no, no, that's what you get for misusing the language
JS is a wonderful language to work with, but you need to invest the time to understand it beyond the "I occasionally use jQuery and hate every minute of it". Of course you'd hate it if jQuery is all you know. Modern JavaScript is quite nice to work with.
// Programmatically trigger a click on the anchor element // Useful if you want the download to happen automatically // Without attaching the anchor element to the DOM // Comment out this line if you don't want an automatic download of the blob content a.click();