Bunu yapabilirsiniz:
HTML:
<input type="button" class="list" value="Download ZipFile" id="download"/>
JS:
$("#download").click(function(){
//this is the data when you send your request
var data = { yourKey1 :'something1', yourKey2:'something2'};
// this is a fake response that we are assumming you got from ajax's response inside success call back
var response = {fileName:'yourFileName.zip' ,filePath : 'YouFilePath'};
$.ajax({
type: "POST",
url: 'yourURL',
data: data,
success: function(response) {
download(response);
}
});
});
var download = function (data){
var link = document.createElement('a');
link.href = data.filePath + data.fileName ;
//below you can define a new name
link.download = data.fileName;
document.body.appendChild(link);
link.click();
}
Örnek:https://jsfiddle.net/3yjt4Lah/8/