Similar question to this: Download a file by jQuery.Ajax.
There is my code:
function saverequest(url, data) {
var response = $.ajax({
url: url,
timeout: requestTimeout,
global: false,
cache: false,
type: "POST",
data: data,
dataType: "json",
success: function () {
var blob = new Blob([response.data], {type : 'application/json'});
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = "export.json";
link.click();
}
});
return response;
}
As i see in this picture, server-side responding with normal json data file.
But this code saving export.json file with "underfined" content inside.
There is a question: how to write data from response to blob object?