Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

Pass Javascript array between pages

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?
Avatar of OriNetworks
OriNetworks

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
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard Korts

ASKER

Works perfectly in FireFox, yet to try on iPad with Safari