I am calling the download servlet on click of the download button. The call is an AJAX call using XMLHttpRequest object.
var xhr = new XMLHttpRequest();
xmlhttp.open("POST","servlet",true); //servlet will be the servlet name
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send(....);
xhr.onreadystatechange = function(){
if (this.readyState == 4 && this.status == 200){
//some logic
}}
Errors i'm getting:
The Save as dialog doesn't appear although Fiddler shows that the document in the response.
server side : header('Content-type',//mmime type); header('Content-Disposition', 'attachment; filename=test.txt');