Re: netWindow - PHP data transfer model
Mark Anderson <[email protected]>
| Newsgroups | gmane.comp.windows.devel.netwindows |
|---|---|
| Message-ID | <[email protected]> |
>If it is a data-request, I
>want the answer to be in a format that Javascript can convert instantly to
>variables. And I am still uncertain how this should be done. Send Javascript
>to be evaluated? (That is my current solution)
>
>
If you are running in mozilla or IE, you can do this, no mess, no fuss:
var jstext = NW_getFileTxt(url);
var data = eval(jstext);
Note that this requires that you send an http header specifying
"Content-Type: text/plain"
It also is synchronous, which is generally not something you want to do
in javascript (stall the user), though it is certainly easier from a
programming standpoint.
Lastly, you'd really want some error checking:
var jstext = NW_getFileTxt(url);
if (!jstext) throw Error("no data back from url '" + url + ': " +
jstext);
var data;
try {data = eval(jstext)}
catch (e) {throw Error("got exception evaluating text of length " +
jstext.length + ": " + e);}
if (!data) throw Error("evaluating text of length " + jstext.length
+ " returned false data " + data + " (typeof=" " + typeof data + ")");
-mda
_______________________________________________
The netWindows developers list: [email protected]
http://netwindows.org/mailman/listinfo/devel_netwindows.org