Most of the time is like that:

Online mode: AJAX requests to server;

Offline mode: No AJAX request, but instead call a JS funtion that is
the equivalent for the AJAX call, but with local stored data.

For example, in my application I have another layer above the ajax
request and a map for ajax -> local

something like that:

action_1: {on: local_action_1, off: ajax_action_1}

and in my app I use Request.do(action_1), where Request is a class
that will verify is is online or offline mode and will do the
corresponding action.

A more clear example would be:

Lets say that we have an app with all countries from the world and
clicking on a country will render a list of towns from that country.
Also, many filters can be applied.
This is an AJAX request that will query server like /get_towns?
country_id=x&min_pop_size=y&any_number_of_filter_params and server
will respond with a JSON with the filtered list.
It is imposible to cache all combination of filters.
Now, if is it offline mode, no request is done, instead a get_towns
(country_id,filter_obj) local function is called that will get the
filtered list from local DB and will return same JSON format as the
ajax request.

Hope things are clearer now.

ways (security mainly)

On May 28, 5:42 pm, nightingale1785 <[email protected]> wrote:
> I read the google gears documents. But I still have too many questions
> on my mind.
>
> I still dont understand how to make Ajax applications work offline?
>
> How do we cache the Ajax response?
>
> As far as I understand,  when any ajax request is given from the
> application,
>
> 1. Initialize gears.
>
> 2. Try to get the response from the local server. (How do we put that
> in the local server? Can we give Ajax URL request in the manifest.json
> to be cached?)
>
> 3. If not available, Give the server request.
>
> Is this the way it works?
>
> I know Its a dumb question . Some one please answer. I am lost!

Reply via email to