Reputation: 36138
I have a mobile web app that I would like to initialize with a bunch of data. Normally, I could fill up a SQL database with tables, columns, and records, but I want to keep everything local and offline.
The best way I can think of doing this is creating a large JSON file that would be retrieved via AJAX, then loaded into localStorage (with maybe a version number to avoid unnecessary loading). However, this would be painful and unpleasant to manage the JSON file (in notepad for example, along with decoding etc).
Any idea or recommendations on how to initialize a mobile web app with tons of data on startup?
Upvotes: 0
Views: 148
Reputation: 198446
"JSON" is the right answer; "file" is not. Have a serverside script generate your JSON from the database. (Actually, you could even pregenerate it, in which case it really would be a file, if the data is static enough.) Dumping a database into JSON is a trivial exercise.
Even better, if the data is huge enough, and if not all of it is needed at once, chunk it: send it in several JSON requests, so the user can start getting some feedback as soon as possible.
Upvotes: 1