I have built 2 buttons Yes and No.
I want to save the answer in a file: Yes or No (of course depend on the button that the end-user will press)
I've already used the Javascript object blob but is not working:
The file testfile1.txt wasn't generated.
I have a subfolder (inside my main folder) named js in which I have the file FileSaver.js.
For this reason, I have:
`src="js/FileSaver.js"`
Implemented in my code. Below my code:
<!doctype html>
<html lang="en">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/FileSaver.js"></script>
</head>
<body>
<button id="save-btn"> yes </button>
<button id="save-btn1"> no </button>
<script>
$("save-btn").click(function{
var blob= new Blob(["yes"],
{type:"text/plain;charset=utf-8"}
);
saveAs(blob,"testfile1.txt");
});
$("save-btn1").click(function{
var blob= new Blob(["no"],
{type:"text/plain;charset=utf-8"}
);
saveAs(blob,"testfile1.txt");
});
</script>
</body>
</html>
Thanks in advance
FileSaver.js, or at least the function definition forsaveAs().