I am building an app that should be able to work offline. I am using jQuery Mobile, PHP, MySQL and jStorage in order to easily use HTML5 localStorage
I am trying to figure out the best way to download the data into the local device localStorage and using it at later stages without slowing down or crashing the browser.
I have around 5000 records (500 Kb of data) in a MySQL table, and I need the app to download all this data so that it can be used at a second stage while offline.
download_script.php returns all the records in JSON format e.g.
{"1":{"1":{"p_bar":"10.30","v_0":"0.0312207306000000","h_vap":"311.78","p_10c":"99.99"}},"2":{"1":{"p_bar":"10.40","v_0":"0.0309405941000000","h_vap":"311.29","p_10c":"0.00"}},
I was wondering if there is any way I could optimize the following script (e.g. in order to not hang the browser, and possibly to display the percentage of data that is being downloaded)
$.ajax({
url: "download_script.php",
cache: false,
success: function(big_json_dump){
$.jStorage.set('some_key', big_json_dump);
}
});
Can this approach be optimized e.g. using radpidjson? How can I change it so to display a live percentage of data downloaded?