Answer the question
In order to leave comments, you need to log in
Is it possible to download file.txt.gz via AJAX and how to unzip it in the browser?
It's just that there are no problems with file.txt:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>AJAX запрос методом GET</title>
</head>
<body>
<h1>AJAX запрос методом GET</h1>
<textarea id="textarea"></textarea>
<br>
<button id="button">Загрузить</button>
<script>
document.getElementById("button").onclick = function() {
var request = new XMLHttpRequest();
request.open("GET", "file.txt", true);
request.onreadystatechange = function() {
if (request.readyState == 4 && request.status == 200) {
document.getElementById("textarea").value = request.responseText;
}
}
request.send();
}
</script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question