HOW TO LOAD DATA FROM A FILE (E.G. SAVE.TXT) USING JAVASCRIPT - Part 2: Save / Load

preview_player
Показать описание
HOW TO LOAD DATA FROM A FILE (E.G. SAVE.TXT) USING JAVASCRIPT
Part 2: Save / Load

HTML
-----------
(input type="file" onchange="loaddata(this)" /)

JAVASCRIPT
---------------------
function loaddata(e){

var reader = new FileReader();

//Do something with load
};

};

// ===== Alternative =========

function loaddata(){

var reader = new FileReader();
//Do something with load
};
};
};
BTC: 3EUQBWZKX9Vcwdffd3cUGATQopxrAQQxJ9
LTC: MBXE6hJgxxFYSD8SjmR7sHCHGTqFXmNGoU
Рекомендации по теме
Комментарии
Автор

thank you for this! for anyone loading a json file with arrays inside instead of just a single line I figured out real quick just declare the load variable as an array instead and remove the index and its brackets from the end of the json parse reader result line and now the array will be equal to your file.. then just iterate through load var array with a for loop as normal.. thats if you only have a simple array though.. I ended up adding the brackets back though since I'm working with several arrays one of which itself contains multiple arrays, and also don't write anything after the reader.readastext(file) because it will run even if data is not loaded yet..

damientyler