In our application, we need to implement the following scenario:
- Request sent from client
- The server processes the request and generates a file
- The server returns the file in response
- The client browser displays a pop-up file download dialog and allows the user to download the file
Our application is an ajax-based application, so it would be very easy and convenient for us to send an ajax request (for example, using the jquery.ajax() function).
But after googilng it turned out that downloading files is possible only when using a POST request without an ajax (as described in this popular SO stream ). Therefore, we needed to implement a uglier and more complex solution, which required the construction of an HTML form structure with nested hidden fields.
Can someone explain in simple words why these ajax requests cannot be used to download a file? What kind of mechanics?
javascript post ajax download
Piotr Sobczyk Feb 04 '13 at 8:01 2013-02-04 08:01
source share