I am using Laravel 5.7 and I want to download zip files on request basis. I send the request to the server via Ajax (the following code), and it returns 200 OK, but does not download the zip file (I can see the content of the zip file in the console though). Also, when I make a regular request (using form to submit the request) it downloads the zip file (as expected), but not with the Ajax request. The reason which I want to use Ajax is to add loading spinner during the downloading the files. Am I missing anything here?
$.ajax({
url: "my_url",
type: 'POST',
async: true,
beforeSend: function() {
$("#loading").show();
},
data: { selectedIds: ids },
success: function(result) {
//
},
complete:function(result) {
$("#loading").hide();
}
});