- When a client makes a request through XMLHttpRequest, the information is sent to the server.
- The server compiles a CSV file and sends it back as the output stream of the response to the client.
Next, the client's browser should display a download dialog box with options to save, open, or cancel the downloaded file. Since the content type is plain text from the server and the content disposition is not set, can we use JavaScript to create a file and prompt the user for download?
I realize this question may seem silly, but I have no other choice but to proceed in this manner.
Although making changes on the server side would only take a minute, I need to handle it on the client side. The responseText property of the XMLHttpRequest object will be plain text, and I need to prompt the user for downloading the text file.
Is this achievable?