<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>FileGen Administration UI</title>
<script src="jquery-3.6.1.min.js"></script>
</head>
<body>
<h1>FileGen Administration UI</h1>
<p><textarea rows="50" cols="200" id="fileGenRequest" name="fileGenRequest"></textarea></p>
<input type="button" value="generate file" onclick="sendRequest()">
<script type="text/javascript">
function sendRequest() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://localhost:8080/generate/file",
data: $("#fileGenRequest").val(),
xhrFields: {
responseType: 'blob'
}
success: function (result) {
console.log(result);
if (result) {
var file = new Blob([result], {
type: 'application/pdf'
});
console.log(file)
var fileUrl = URL.createObjectURL(file);
window.open(fileUrl);
} else
console.log("ОШИБКА!!!")
}
})
}
</script>
</body>
</html>