Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript : Save/Load array to a file?

Tags:

javascript

(This is for local use only, using WAMP) I have some Javascript's that create a array containing some string and objects. I would like to save this array to a file, so that i can later load it into another JavaScript.

I have seached Google all night, but can seem to find any way of doing this :(

like image 826
Dennis Sødal Christensen Avatar asked Nov 24 '25 13:11

Dennis Sødal Christensen


2 Answers

use JSON.stringify(myarray) first, then you can use AJAX to send the data to the server. You can use file_put_contents(php) to save the file to the server's disk...you can retrieve the array and use it later using JSON.parse(array_from_file);

like image 188
StaleMartyr Avatar answered Nov 26 '25 03:11

StaleMartyr


You can send json to php server and from there you can write it to a json file.

like image 33
Vicky Gonsalves Avatar answered Nov 26 '25 04:11

Vicky Gonsalves



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!