I’m developing a very simple web application, it just display’s static data and has no server, just html, css and javascript. One feature this application needs is to read and write to a log file every time the application is launched (index.html is opened in a browser). The log file is extremely simple, it should log 1 or 0 to a .txt file every time the app is launched. When the app is launched (open index.html) it should read the last value of the log file, save it as a variable for further logic and than write to the log file again. Is this possible with pure javascript/ jQuery? I’m trying to avoid using a node.js server or any databases as my client wants this as simple as possible. I’ve tried this jQuery below but I get this error… “jquery-2.2.3.js:9203 XMLHttpRequest cannot load’”. Any help is greatly appreciated, Thanks.
$(document).ready(function() {
// Get Log File
function getLog() {
$.ajax({
url: 'file:///xxx/xxx/Desktop/app/logfile.txt', // fake path obvi
dataType: 'text',
success: function(text) {
$("#Adaptors").text(text);
setTimeout(getLog, 10000); // refresh every 10 seconds
console.log("got Log: ", text);
}
})
}
getLog();
});