Solved

Pass Javascript array between pages

Posted on 2015-01-21
3
66 Views
Last Modified: 2015-01-22
We have an internet App that runs on iPads in the field. It uses a MySQL database on the server.

There is a part lookup capability that we think might be time consuming over the web in the field if no WiFi.

I am thinking of downloading the parts table (only about 600 records) to the ipad & building a Javascript array that can be used locally; I'd like to build the array in the login program (to avoid duplicating it later) & passing it to the program that needs it.

Can that be done? How does one "pass" the Javascript Array?

Maybe with Json?
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40562546
As far as downloading the data from the server, json is probably the way to go. One thing to keep in mind is that javascript doesn't always perform very well with large object sizes. 600 may be ok but with a mobile device such as an ipad im not sure.

For caching the data you have 2 options.
First option is using an ajax call to ask a web service for a list of parts and telling the ajax call to cache the data so it doesn't try pulling the list again. I am familiar with the jQuery ajax calls in which you just set cache: true when performing the ajax call. Call this ajax everywhere it is needed and it should just pull the results from local cache instead of downloading again.

Second option is storing the object in a cookie with javascript. With this option however you are limited by how much data the browser will allow in the cookie which I think is typically limited at 4kb. You also have web storage if the browser supports HTML5. http://www.w3schools.com/html/html5_webstorage.asp
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 40562733
Hi,
if your app is an mobile app based on HTML and Javascript you might be able to use the iOS offline cache features as well as HTML5 local storage.
A good sample application can be found here:
http://www.chuckmcquilkin.com/simply-list-ios-web-app-with-local-storage/
including links to the official Apple documentation for Offline Application Cache.
HTH
Rainer
0
 

Author Closing Comment

by:Richard Korts
ID: 40564631
Works perfectly in FireFox, yet to try on iPad with Safari
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question