I am working on a small Project for myself. I wont upload a webpage but only run the files on localhost on my machine(HTML,CSS,JAVASCRIPT)
function saveData() {
$.post("testFile.txt", "New Content of the File ");
}
function getData() {
$.when($.get("testFile.txt")).done(function(requestedData) {
alert(requestedData);
});
}
Ok so this is basically a dummy Project to explain my Problem. The methods are called by two different Buttons with an "onclick" event. First Button which calls "getData()" works fine. The testFile.txt is located right next to the Html and Javascript file, and the getData() method correctly alerts the content of the text file as a String.
My Problem: How do I make the saveData() method work? Do I misunderstand the $.post() method? (https://www.w3schools.com/jquery/jquery_ajax_get_post.asp)
I read so many forums and topics the last days but none of them solves the problem the way I´d need it, because I don´t wanna do all these difficult looking http-requests things - just reading and writing to this file that is located in the same folder then all my html and javascript Files
Thanks :)
via Johannes Beiser
No comments:
Post a Comment