Re: netWindow - PHP data transfer model
Mark Anderson <[email protected]>
| Newsgroups | gmane.comp.windows.devel.netwindows |
|---|---|
| Message-ID | <[email protected]> |
First, we should clarify some factors:
- I presume you realize that if the user refreshes the page, or clicks a
link that replaces the page,
then the iframe used for the data channel will be destroyed alone with
all its state.
So it can't be used for persistence of javascript variables across pages.
- Regardless of what mechanism is used for fetching data at a url, in
the end, the browser's cache
is used in the same way as if you typed the url in the address bar. You
will want to make
sure that your server sends appropriate cache headers so that no
roundtrip is needed (or
just a If-Modified-Since check). Note that this means that you can *not*
be setting cookies
in your data url handler, because cookies kill caching. Whether you use
Last-Modified,
Expires, or Cache-Control depends on the nature of your requests.
- How large is the data? Is it more than a 100Kbytes?
You'll want to make sure your server accepts a gzip transfer encoding.
- How expensive is it for the server to compute the data? Here too, if
it is expensive
you'll want to leverage browser caches (both to relieve the server and
shorten client
response time). You may want to also use "output caching" techniques
on the server.
- Will a single page be making multiple data requests? How many? In
series or parallel?
- What browser makes and versions are you targeting?
- What will the data sent back be? A text string you parse? A javascript
expression? html?
Christian Boulanger wrote:
>1) win = create_hidden()
>
> - creates a hidden Iframe to load data in
>
You don't need to do this yourself. NW does it for you on demand.
>
>2) load(object win,string remote_procedure, string/array parameters [,URL])
>
>
>- loads from an optional URL (for example http:// ... get.php, takes a
>default value if not given), calling procedure x with parameters y into
>window object win
>- this should work for both visible windows and hidden iframes.
>- the problem here is how to encode the parameters if they are not just a
>string for the URL query string. Do you have any ready-made solution for
>that. I really want to be able to send arrays through this method.
>
__env__.addToPageQueue(url, dest_div_node, false, notifyobj, notifymeth)
dest_div_node is a DOM node whose content you want set to what is
fetched from the url.
notifyobj[notifymeth] will be called when it is ready.
you can get the content back by doing dest_div_node.innerHTML if it is
html content.
javascript has native functions for url encoding.
escape() and unescape() are always available, but of dubious semantics.
encodeURIComponent() and decodeURIComponent() are better, but they are
missing from Safari/Konq and IE5.0 PC.
You could serialize an array into a single string by something like
arr.join('|') and then split it on the server side.
>
>3) variable x = retrieve(object win, string variable name);
>
>- retrieves variable x from window win (visible/invisible iframe etc). This
>relates to my last post: how best to encode a variable (including
>multidimensional arrays) so that javascript can read and assign this
>variable
>
>4) variable y = request(string remote_procedure, string/array parameters
>[,URL])
>
>- this is a combination of 1-3: first an iframe is create if it does not
>exist already, then the request is sent, the result is queried from the
>iframe content, and returned.
>
>
>
I think these are covered by 2.
-mda
_______________________________________________
The netWindows developers list: [email protected]
http://netwindows.org/mailman/listinfo/devel_netwindows.org