To download file I am using ajax. I have three status:
"Download file" - before you click on the link.
"File is downloading..." - while the file is downloading
"Download file" - if the file was generated successful
"Error while downloading file" - if there was any error while download the file.
I'm using JSP, jquery ajax. How to determinate that there was an error with downloading the file with using ajax or the download was successfull.
You cannot download a file using ajax, and make it useful. Ajax response is loaded into javascript memory. Javascript dont have disk access to save that file.
So better do it in normal way using header "content-type" Content-Disposition: attachment; filename="file name.ext" using normal request.
This will download file and browser will provide user an option to save file. Also note that this wont reload your page.