I have a small web application using JS. It lies locally and should also be used locally. Without PHP and other things.
Data is written to the local file (located in the same folder as index.html). The data itself is just one duble number (1 line and all).
How can I, in JS code, count this number into a variable? ajax, jquery and does not help. I need to bring this variable to alert() , and it displays to me either [Object object] or undefined . I already tried a bunch of ways from Google - nothing helped.
UP:
url: file: /// C: /Users/ROCKer/Desktop/test/index.html
var t; $.ajax({ type: "GET", url: "1.txt", success: function(text) { t = text; }, error: function() { // An error occurred } }); alert(t);
[Object object]orundefined- Grundyvar a = 10, in this case, after loading and executing the script, you can access the variableaand get the value10- Grundy