I have a javascript app that sends ajax POST requests to a certain URL. Response might be a JSON string or it might be a file (as an attachment). I can easily detect Content
Here is how I got this working https://stackoverflow.com/a/27563953/2845977
$.ajax({
url: '',
success: function(data) {
var blob=new Blob([data]);
var link=document.createElement('a');
link.href=window.URL.createObjectURL(blob);
link.download="";
link.click();
}
});
$.ajax({
url: '',
success: download.bind(true, "", "")
});