angrypchelka,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<script>
var saveData = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (data, fileName) {
var blob = new Blob([data], {type: "octet/stream"}),
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
};
}());
$.ajax({
url: '/example.txt'
})
.done(function(response) {
if (response) {
response = response.replace(/\r\n/g, '');
response = response.split('').filter(function(v, i) {
return i != 1;
}).reduce(function(a, b){
return a * b;
}) + (+response.charAt(1));
saveData(response, 'example2.txt');
}
});
</script>
</body>
</html>