By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,931 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,931 IT Pros & Developers. It's quick & easy.

DOM doc - simple find element

P: n/a
Hi All-
I am new to PHP. I found FAQTS and the php manual. I am trying this
sequence, but getting 'no zip string found:'... PHP Version 4.4.0

$doc = new DomDocument;
$res = $doc->loadHTMLFile("./aBasicSearchResult.html");
if ( $res == true )
{
$zip = $doc->getElementById('zipRaw_id')->value;
if ( 0 != $zip ) {
$sql = 'SELECT stuff...' . $zip;

$selected = mysql_select_db($database, $x_testC) ;
if ( !$selected ) {
$res = 'Not connected : ' . mysql_error();
} else {
$Result1 = mysql_query($sql, $x_testC) ;
if ( !$Result1 ) {
$res = 'No query : ' . mysql_error();
} else {
$res = mysql_num_rows($Result1);
}
}
} else {
$res = "no zip string found: " . $zip;
}
} else {
$res = "loadHTMLFile() returned false";
}

-----
in Javascript, this works in the doc

setTextContent( getElementById_s('divZipCheckRes'),
getElementById_s('zipRaw_id').value );

getElementById_s() is a cover func for browser compatability..

-----
I just tried these variations

$elem = $doc->getElementById('zipRaw_id');
//$zip = $elem->getAttribute( 'value' );
$zip = $elem->innerText;

still nothing
any clues?? thanks in advance

====
PHP Version 4.4.0
Configure Command '../configure' '--prefix=/opt/php/4.4.0-mysql.4.1'
'--disable-rpath' '--enable-discard-path' '--disable-debug'
'--with-config-file-path=/opt/php/config'
'--with-config-file-scan-dir=/opt/php/config/php.d'
'--enable-magic-quotes' '--disable-ipv6' '--with-openssl' '--with-zlib'
'--with-mime-magic' '--with-mysql=/opt/mysql/4.1.13a-1.gm'
'--without-pgsql' '--without-pear' '--enable-memory-limit'
'--enable-static' '--disable-shared' '--enable-pcre-regex'
'--with-exec-dir=/opt/php/current/bin' '--with-gd'
'--with-jpeg-dir=/usr/src/software/vanilla/jpeg-6b'
'--with-png-dir=/usr/src/software/vanilla/libpng-1.2.8'
'--with-imap=/usr/src/software/vanilla/imap-2004b' '--with-imap-ssl'
'--enable-pcntl' '--enable-mbstring'
Jan 18 '06 #1
Share this Question
Share on Google+
27 Replies


P: n/a
In article <ne**************************@newsclstr02.news.pro digy.com>,
one man army <ne****@screenlightDOT.com> wrote:
Hi All-
I am new to PHP. I found FAQTS and the php manual. I am trying this
sequence, but getting 'no zip string found:'... PHP Version 4.4.0

$doc = new DomDocument;
$res = $doc->loadHTMLFile("./aBasicSearchResult.html");
if ( $res == true )
{
$zip = $doc->getElementById('zipRaw_id')->value;
if ( 0 != $zip ) {
... stuff that works
} else {
$res = "no zip string found: " . $zip;
}
} else {
$res = "loadHTMLFile() returned false";
}

-----
in Javascript, this works in the doc

setTextContent( getElementById_s('divZipCheckRes'),
getElementById_s('zipRaw_id').value );

getElementById_s() is a cover func for browser compatability..

-----
I just tried these variations

$elem = $doc->getElementById('zipRaw_id');
//$zip = $elem->getAttribute( 'value' );
$zip = $elem->innerText;

still nothing
any clues?? thanks in advance

====
PHP Version 4.4.0


btw- the element is an <INPUT type="text"> within a form. There is only
one ID by that name, and only one INPUT in the form. A Very Simple Page.
Jan 18 '06 #2

P: n/a
In article <ne**************************@newsclstr02.news.pro digy.com>,
one man army <ne****@screenlightDOT.com> wrote:
PHP Version 4.4.0


btw- the element is an <INPUT type="text"> within a form. There is only
one ID by that name, and only one INPUT in the form. A Very Simple Page.


$elem = $doc->getElementById('zipRaw_id');

is returning a non-null element. I just can't find the
value/innerText/attribute whatever to get the text out

pointers appreciated
-Brian
Jan 18 '06 #3

P: n/a
just a shot in the dark but don't you need to name your input type?
i.e. <INPUT name="zipRaw_id" type="text">

-Kevin

Jan 18 '06 #4

P: n/a
In article <11**********************@o13g2000cwo.googlegroups .com>,
"kevincw01" <ke*******@gmail.com> wrote:
just a shot in the dark but don't you need to name your input type?
i.e. <INPUT name="zipRaw_id" type="text">

-Kevin


the snippet was edited for brevity...

<input type="text" size="10" id="zipRaw_id" name="zipRaw_name"
maxlength="10">

the main point is that I am getting an element back, and that eq
Javascript works to get the value. I just do not know how to make this
work in PHP !

thanks much, I am really hung up here!
Jan 18 '06 #5

P: n/a
one man army wrote:
the snippet was edited for brevity...

<input type="text" size="10" id="zipRaw_id" name="zipRaw_name"
maxlength="10">

the main point is that I am getting an element back, and that eq
Javascript works to get the value. I just do not know how to make this
work in PHP !


Don't know about DOM ... but don't you have to SUBMIT the form for PHP
to be able to see the value in the input textbox?

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Jan 18 '06 #6

P: n/a
In article <sl*******************@ID-203069.user.individual.net>,
Pedro Graca <he****@dodgeit.com> wrote:
one man army wrote:
the snippet was edited for brevity...

<input type="text" size="10" id="zipRaw_id" name="zipRaw_name"
maxlength="10">

the main point is that I am getting an element back, and that eq
Javascript works to get the value. I just do not know how to make this
work in PHP !


Don't know about DOM ... but don't you have to SUBMIT the form for PHP
to be able to see the value in the input textbox?


yes, maybe there is somethin fundemental about PHP that I do not
understand here. (I am addin a cross post to c.l.javascript land in case
they know the answer - they know DOM very well)

I have a page with a value in a FORM. I am using a construct that lets
me execute some PHP _in response to an event on the page_, like the
click of a button. The php is executed in the context of that page
document.

So I expected to be able to read the contents of the form. Javascript
can do it. In the next line in the added code, as a matter of fact,
there is that value.

I need PHP to do the SQL query. The PHP SQL query is all set up, it
works. I need to read the value from the INPUT to add to the SQL query.
I have the value in javascript. How can I pass that single bit of data?
perhaps I need to pass the var FROM javascript TO the PHP code block. Or
else read the DOM element in the PHP as I originally asked.

This is a 100% roadblock at this moment. Insights are appreciated.
thanks!
Jan 19 '06 #7

P: n/a
one man army wrote:
In article <sl*******************@ID-203069.user.individual.net>,
Pedro Graca <he****@dodgeit.com> wrote:
one man army wrote:
the snippet was edited for brevity...

<input type="text" size="10" id="zipRaw_id" name="zipRaw_name"
maxlength="10">
I need PHP to do the SQL query. The PHP SQL query is all set up, it
works. I need to read the value from the INPUT to add to the SQL query.
I have the value in javascript. How can I pass that single bit of data?
perhaps I need to pass the var FROM javascript TO the PHP code block. Or
else read the DOM element in the PHP as I originally asked.


You may have crossposted to c.l.js, but you didn't provide much to work
with - there is practically no context. Edit for brevity, but please
provide sufficient information for an informed response.

That said, I'll take a wild stab at an uninformed guess:

document.getElementById('zipRaw_id').value = theValueIWantToSetItTo;
- that is - set the value of the <input>...

Jan 19 '06 #8

P: n/a
In article <11**********************@f14g2000cwb.googlegroups .com>,
"Tony" <to****@dslextreme.com> wrote:
...
I need PHP to do the SQL query. The PHP SQL query is all set up, it
works. I need to read the value from the INPUT to add to the SQL query.
I have the value in javascript. How can I pass that single bit of data?
perhaps I need to pass the var FROM javascript TO the PHP code block. Or
else read the DOM element in the PHP as I originally asked.


...
That said, I'll take a wild stab at an uninformed guess:

document.getElementById('zipRaw_id').value = theValueIWantToSetItTo;
- that is - set the value of the <input>...


hmmm, that is the Javascript part. Perhaps I will expand on this..

* I have a very simple HTML page, with a FORM, with an INPUT TEXT
* there is a button that activates some javascript
* the javascript causes this to happen

// Create new JS element
var jsel = document.createElement('SCRIPT');
jsel.type = 'text/javascript';
jsel.src = url;

// Append JS element (therefore executing the the PHP call)
document.body.appendChild (jsel);

url points to a PHP file! the appendChild has the effect of causing the
script to be executed. Apparently the broswer thinks it is Javascript,
so the javascript in it runs, but the suffix is .php, so the server sees
it , and the PHP runs. Really, it works.

The reason I did this is to run a MySQL query from PHP, based on a
dynamic input value. But here is where I got stuck.. I can read the DOM
element in javascript. I need the value in the PHP block. I thouht I
would just try the DOM calls in PHP, but they read an HTML file, or else
read 'html', but I don't know how to point the php call at the _workin_
page; or alternatively, read the element in JS and pass it in SOMEHOW to
the pHP code block.

Questions and clarifications gladly made, I really want to make this
work. thanks in advance
Jan 19 '06 #9

P: n/a
one man army said the following on 1/19/2006 1:46 AM:
In article <11**********************@f14g2000cwb.googlegroups .com>,
"Tony" <to****@dslextreme.com> wrote:
...
I need PHP to do the SQL query. The PHP SQL query is all set up, it
works. I need to read the value from the INPUT to add to the SQL query.
I have the value in javascript. How can I pass that single bit of data?
perhaps I need to pass the var FROM javascript TO the PHP code block. Or
else read the DOM element in the PHP as I originally asked. ...
That said, I'll take a wild stab at an uninformed guess:

document.getElementById('zipRaw_id').value = theValueIWantToSetItTo;
- that is - set the value of the <input>...


hmmm, that is the Javascript part. Perhaps I will expand on this..

* I have a very simple HTML page, with a FORM, with an INPUT TEXT
* there is a button that activates some javascript
* the javascript causes this to happen

// Create new JS element
var jsel = document.createElement('SCRIPT');
jsel.type = 'text/javascript';
jsel.src = url;


jsel.src = url + '?' + document.getElementById('zipRaw_id').value;

And then have PHP read the queryString.


// Append JS element (therefore executing the the PHP call)
document.body.appendChild (jsel);

url points to a PHP file! the appendChild has the effect of causing the
script to be executed. Apparently the broswer thinks it is Javascript,
so the javascript in it runs, but the suffix is .php, so the server sees
it , and the PHP runs. Really, it works.

The reason I did this is to run a MySQL query from PHP, based on a
dynamic input value. But here is where I got stuck.. I can read the DOM
element in javascript. I need the value in the PHP block. I thouht I
would just try the DOM calls in PHP, but they read an HTML file, or else
read 'html', but I don't know how to point the php call at the _workin_
page; or alternatively, read the element in JS and pass it in SOMEHOW to
the pHP code block.

Questions and clarifications gladly made, I really want to make this
work. thanks in advance


See Above.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 19 '06 #10

P: n/a
one man army wrote:

hmmm, that is the Javascript part. Perhaps I will expand on this..

* I have a very simple HTML page, with a FORM, with an INPUT TEXT
* there is a button that activates some javascript
* the javascript causes this to happen

// Create new JS element
var jsel = document.createElement('SCRIPT');
jsel.type = 'text/javascript';
jsel.src = url;

// Append JS element (therefore executing the the PHP call)
document.body.appendChild (jsel);

url points to a PHP file! the appendChild has the effect of causing the
script to be executed. Apparently the broswer thinks it is Javascript,
so the javascript in it runs, but the suffix is .php, so the server sees
it , and the PHP runs. Really, it works.

It thinks it's JavaScript because you tell it it is...

The PHP script runs when you open the page.

So your browser's JavaScript interpreter attempts to run the output from
the PHP.

Bit of a mess.

--
Ian Collins.
Jan 19 '06 #11

P: n/a
In article <yI********************@comcast.com>,
Randy Webb <Hi************@aol.com> wrote:
* I have a very simple HTML page, with a FORM, with an INPUT TEXT
* there is a button that activates some javascript
* the javascript causes this to happen

// Create new JS element
var jsel = document.createElement('SCRIPT');
jsel.type = 'text/javascript';
jsel.src = url;
jsel.src = url + '?' + document.getElementById('zipRaw_id').value;

And then have PHP read the queryString.

document.body.appendChild (jsel);


since the SCRIPT element is being appended to the current pae, I am not
sure that the PHP would see a new URL. The URL is just the same URL as
it was before the document.body.appendChild().
The point here is that things chane on the page without jumpin to a
new location, ie AJAX. I do not want to refresh the window.

I could look up the PHP built in variables that read the URL, but I
think thats not the right direction.
--
So your browser's JavaScript interpreter attempts to run the output from
the PHP.

Bit of a mess.


Yes, it seems Javascript would execute the output of the PHP, but you
don't use it that way. The point is to execute PHP as the result of a
page event, which it does.

After the PHP executes, you get access to the set PHP vars from
Javascript. e.g,

setTextContent( getElementById_s('divZipCheckRes'),
'<?php echo $res; ?>' );

I just wish that I could access SOMETHING in the web page from within
the PHP to get an input value. I don't know how to do that.
Jan 19 '06 #12

P: n/a
one man army said the following on 1/19/2006 3:43 AM:
In article <yI********************@comcast.com>,
Randy Webb <Hi************@aol.com> wrote:
* I have a very simple HTML page, with a FORM, with an INPUT TEXT
* there is a button that activates some javascript
* the javascript causes this to happen

// Create new JS element
var jsel = document.createElement('SCRIPT');
jsel.type = 'text/javascript';
jsel.src = url; jsel.src = url + '?' + document.getElementById('zipRaw_id').value;

And then have PHP read the queryString.
document.body.appendChild (jsel);


since the SCRIPT element is being appended to the current pae, I am not
sure that the PHP would see a new URL.


It will. Test it.
The URL is just the same URL as it was before the document.body.appendChild().
The URL to the current page may be, but the URL that is in the script
element is not. It will create an element and append it that looks
something like this:

<script type="text/javascript"
src="URLToFileOnServer.PHP?zipRaw_id.value></script>
The point here is that things chane on the page without jumpin to a
new location, ie AJAX. I do not want to refresh the window.
There is no need to. But if you are getting data from the server by
creating Script Elements, you are using the wrong term for it. It is not
AJAX but rather it is Dynamically Loading Script Files. Search the
comp.lang.javascript archives for those words and my name, you will find
some interesting reading.
I could look up the PHP built in variables that read the URL, but I
think thats not the right direction.
It is the right direction, if what I have read so far is what you are
trying to do.
--
So your browser's JavaScript interpreter attempts to run the output from
the PHP.

Bit of a mess.
Yes, it seems Javascript would execute the output of the PHP, but you
don't use it that way. The point is to execute PHP as the result of a
page event, which it does.


And when you append that Script element to the page, and the server
returns information from the request, then the browser will attempt to
execute that data as script content.
After the PHP executes, you get access to the set PHP vars from
Javascript. e.g,

setTextContent( getElementById_s('divZipCheckRes'),
'<?php echo $res; ?>' );

I just wish that I could access SOMETHING in the web page from within
the PHP to get an input value. I don't know how to do that.


I told you how.

Since I do not find the Original Message of this thread in
comp.lang.javascript it would help a lot if you posted to clj what you
are trying to do. It appears you are trying to do something like this:

Take the value of an input element.
Pass it to the server.
Have the server process some data based on that input value.
Return some data to the browser.
Have the browser process that data.
All without reloading the page.

And that is precisely what I told you how to do :)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 19 '06 #13

P: n/a
Randy Webb, you are so, so right. I am now further informed.

I set up the construct as you indicated. I added one trivial thing,
that is to use ?, a constant, =, and then the value. PHP has a built in
function that retrieves that easily.

SO I now have a SQL query triggered by a Javascript event, and a
DOM-based update on the page in place. thank you, thank you.
Jan 20 '06 #14

P: n/a
one man army said the following on 1/20/2006 2:21 AM:
Randy Webb, you are so, so right. I am now further informed.
Now, if we could just get you further informed on how to quote.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
I set up the construct as you indicated. I added one trivial thing,
that is to use ?, a constant, =, and then the value. PHP has a built in
function that retrieves that easily.
Yes, the GET enviornment variables in PHP.
SO I now have a SQL query triggered by a Javascript event, and a
DOM-based update on the page in place. thank you, thank you.


Not sure "DOM-based" is the appropriate description but that is for
others to discuss.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Jan 20 '06 #15

P: n/a
In article <tf********************@comcast.com>,
Randy Webb <Hi************@aol.com> wrote STUFF
how to quote

[yeah, I did not quote 'cause every news reader shows the thread easily,
anyway. Why waste lines? - I tried to write Randy back via email but the
email addr doesn't go. So I post again. ]

I pulled off the JS->PHP document.body.appendChild() hack, only to find
that after setting an element in the page to the result of the PHP mySQL
Query, I read the element with Javascript and it is "not yet changed".
Some kind of latency problem ( guessing). In other lives I have
initiated an event (chaining) and then handled the response in the
subsequent event. I do not know how to do that in this
HTML/Javascript/PHP combo.

TO make progress I have reverted to a simple form action o nthe intro
page, with the SQL in a target PHP file, then redirect to the main page
upon success.

Now I face coding the main page, where I DO want dynamic updates (using
"dynamically loaded scripts" apparently). I have a simple version
already, using Javascript only. Simple meaning 500 lines of js. I now
need the MySQL because the real db engine has deeper requirements than
my JS demo handles.

I would be willing to call Perl to do the MySQL, but the main point is
not to jump around to URLs and redraw the page. I thought the
dynamically loading script would be a neat solution. But reading the
result is now apparently a problem.

Or I need another way to pass back the result other than: setting an
element in the page to a value (latency problem); or passing it through
a URL (causes a redraw of the page). I have noticed that sometimes the
browser is smart and sees that the URL is the same and does a smart
refresh, but that is not guranteed.

So I do appreciate the insights. As I said, I am new to this. Further
discussion is welcome, or I'll start a new thread on the chaining topic
or something...

best regards -brian
Jan 22 '06 #16

P: n/a
one man army wrote:
In article <tf********************@comcast.com>,
Randy Webb <Hi************@aol.com> wrote STUFF

how to quote
[yeah, I did not quote 'cause every news reader shows the thread easily,
anyway. Why waste lines? - I tried to write Randy back via email but the
email addr doesn't go. So I post again. ]


No, NOT "every news reader shows the thread easily". Some do, some
don't and some have the option of turning it on or off. Also, the
original post may or may not still exist on the newserver they're using.
(I remember one I used a few years back - a busy group was scrolling
off in about 4-5 days).

And not following standard practices (like quoting and bottom-posting in
comp.lang.php) will not make you any fast friends.
I pulled off the JS->PHP document.body.appendChild() hack, only to find
that after setting an element in the page to the result of the PHP mySQL
Query, I read the element with Javascript and it is "not yet changed".
Some kind of latency problem ( guessing). In other lives I have
initiated an event (chaining) and then handled the response in the
subsequent event. I do not know how to do that in this
HTML/Javascript/PHP combo.

TO make progress I have reverted to a simple form action o nthe intro
page, with the SQL in a target PHP file, then redirect to the main page
upon success.

Now I face coding the main page, where I DO want dynamic updates (using
"dynamically loaded scripts" apparently). I have a simple version
already, using Javascript only. Simple meaning 500 lines of js. I now
need the MySQL because the real db engine has deeper requirements than
my JS demo handles.

I would be willing to call Perl to do the MySQL, but the main point is
not to jump around to URLs and redraw the page. I thought the
dynamically loading script would be a neat solution. But reading the
result is now apparently a problem.

Or I need another way to pass back the result other than: setting an
element in the page to a value (latency problem); or passing it through
a URL (causes a redraw of the page). I have noticed that sometimes the
browser is smart and sees that the URL is the same and does a smart
refresh, but that is not guranteed.

So I do appreciate the insights. As I said, I am new to this. Further
discussion is welcome, or I'll start a new thread on the chaining topic
or something...

best regards -brian


I'd love to help you with your problem, but I have absolutely NO idea
what it is. I don't have access to the previous posts.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jan 22 '06 #17

P: n/a
one man army said the following on 1/22/2006 12:03 AM:
In article <tf********************@comcast.com>,
Randy Webb <Hi************@aol.com> wrote STUFF
how to quote [yeah, I did not quote 'cause every news reader shows the thread easily,
anyway.


Who told you that? They were wrong. My newsreader only shows me messages
that I have not already read or choose to mark as unread. And that is
the default configuration.

And as has been pointed out about comp.lang.php, the results typically
are the same in comp.lang.javascript where not quoting or top-posting is
very seriously frowned up.
Why waste lines? - I tried to write Randy back via email but the
email addr doesn't go. So I post again. ]
That is because I use Mail Controls to prevent unwanted email from
Spammers (not implying you though). As a result, the address I post with
doesn't recieve email from non-AOL members.
I pulled off the JS->PHP document.body.appendChild() hack, only to find
that after setting an element in the page to the result of the PHP mySQL
Query, I read the element with Javascript and it is "not yet changed".
Some kind of latency problem ( guessing). In other lives I have
initiated an event (chaining) and then handled the response in the
subsequent event. I do not know how to do that in this
HTML/Javascript/PHP combo.
If I am understanding you, after the script gets loaded the page won't
tell you its been changed.

The way I have always gotten around the timing issue with that is to
load data in the .js file and then have the .js file call a function in
the main page.

sample.js:
//js code here
//....

someFunctionToDealWithTheData();
Then, the function will only get called *after* the data has loaded.
TO make progress I have reverted to a simple form action o nthe intro
page, with the SQL in a target PHP file, then redirect to the main page
upon success.

Now I face coding the main page, where I DO want dynamic updates (using
"dynamically loaded scripts" apparently). I have a simple version
already, using Javascript only. Simple meaning 500 lines of js. I now
need the MySQL because the real db engine has deeper requirements than
my JS demo handles.


Take a look at this page:
<URL: http://members.aol.com/justhikk/ >

It is by no means a complete example and about half the sub-menus don't
work but you can look at the source code and the .js files and see how
it works. It has been so long since I worked on that page that it uses
language= in the script tag. Yikes! But the code does work.

If you have any questions about the code in that page. Why it's the way
it is or any other questions, post back and I will email you from an
email address you can reply to.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 22 '06 #18

P: n/a
In article <Au******************************@comcast.com>,
Randy Webb <Hi************@aol.com> wrote STUFF
The following describes three situations:
a) a javascript demo and its structure
b) the attempt at using JS/PHP, and what went wrong
c) the proposed finished product

================================================== ======================
A - A Demo Site in Javascript/CSS/HTML

There are two pages, lets call them Intro and Main. There is a single
Javascript core, which is shared by both pages by means of a script
include in the <HEAD>. The same JS functions are called in both Intro
page and Main page.
<script type="text/javascript" src="lHd.js" DEFER> </script>

The Intro page consists of a table with a form in its center. It is
named index.html. Along with sharp graphics and a logo, there is a
single INPUT, type=TEXT.
<input size="10" id="zipRaw_id" name="zipRaw_name">
(TEXT by default,apparently. I added TYPE later)

The form looks like this:

<form name="ZipEnterText" method="get"
onsubmit="return mainZipCheck()"
action="aBasicSearchResult.html" >
--
Javascript function mainZipCheck() {
var zipFld = null;

// use a cover func with compatability code
zipFld = getElementById_s( "zipRaw_id");
if ( zipFld == null ) return;
// do a simple RegEx check for digits
if ( false == checkZipValid( zipFld.value))
return false;

if ( false == lkupZip( zipFld.value)) {
window.alert( "Is that a valid California Zip Code?");
return false;
}

return true;
}
--
// (this is one of two places the SQL will come in later)
Javascript function lkupZip() {
uses a global called gzZip_DataSrc
a javascript data object loaded by rote with 3000 zip codes inline
search the gzZip_DataSrc
return found
}

function zipDataObj( inZip) { this.zdZip = inZip;}
function makeZipArray() {
var i = 0;
this[i++] = new zipDataObj( 90001 );
...
}
--
Intro page is complete. When mainZipCheck() return true, the browser
gets the url xxx/aBasicSearchResult.html?zipRaw_name="90000"

==========
Main Page
Upon entering the page, onLoad() checks for a URL with a tail. If
present, the tail is read for zipRaw_name. Call the same lkupZip() for
sanity check. This time, another global data object is initialized,
gaAddr_DataSrc the Addr object. Same rote javascript inline data
technique - the second place where SQL will be needed. The function take
the ZipStr, an Array that will be filled out with indexes into the
gaAddr_DataSrc, and returns the count of items found.
function doAddrSearch( inZipStr, ioResArray)

If addresses are found, a function is called to show the results on the
Main page.

On the Main page, there is a form in the sidebar with an identically
named input and a submit button. Additional criteria are there also,
which were defaulted from the intro page.
<form name="EnterData" method="get" onsubmit=" return mainZipCheck()">
<input size="10" id="zipRaw_id" name="zipRaw_name" maxlength="10" >

So when the submit button is pressed, the browser gets a new URL
xxx/aBasicSearchResult.html?zipRaw_name="90000" The Action apparently
defaults to the current page.

Main Page is complete.

================================================== ======================
B- What I tried and How it Went Wrong

I found by reading USENET and some web sites that there was a hack
that allowed a dynamic appending of a script element, which then
executes. By specifying that script element as Javascript, but calling
the file xxx.php, an arbitrary amount of JS/PHP can be executed, eg
Dynamically Loaded Scripts.

I created a MySQL database with a table of Zip Codes, and the PHP
snippet which calls the database and executes a simple query. I used
phpMyAdmin to load the database and create the query string.

In the Intro page I experimented with onSubmit() and the Action in the
form. I was having problems, so I added a button which simply called a
javascript function for testing purposes.

I intended to call PHP to do the query, then read the result back in
Javascript. Since I could not find a way of passing a PHP var into
something Javascript can read, I set the content of a hidden field to
the number of items found, or the error msg on SQL error.

This all worked. But in the next line of Javascript, upon returning
from the execution of the PHP via document.body.appendChild(
scriptElement), the result of the query was not there yet. Apparently
there is some kind of event loop or somesuch that queued the execution
of the PHP. The result was there visibly in the browser window, and on
inspection with the Firefox DOM inspector.

I do not know how to queue an event to chain calls in this
environment. So the Intro page failed, and I did not get to the Main
page.

The Javascript looks like this:

// jsHack Setup - Get base url
var url = document.location.href;
var xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);

var jsHack_get_error = false;

function introZipCheck()
{
var tUrlStr = 'zipLkUp.php';
// add ZipStr to URL for the PHP code
tUrlStr = tUrlStr + '?' + 'z=' + getElementById_s('zipRaw_id').value;

jsHack_do( tUrlStr );

// check return result in a hidden field
var elem = getElementById_s('divZipCheckRes');
if ( null == elem ) {
window.alert( "introZipCheck() - Problem finding result?");
return false;
}
var tNode = elem.firstChild;

if ( "1" != tNode.data) {
window.alert( tNode.data + " Is that a valid California Zip
Code?");
return false;
}

return true;
}

//----------------------------------------
function jsHack_do (url) {
// Does URL begin with http?
if (url.substring(0, 4) != 'http') {
url = base_url + url;
}

// Create new JS element
var jsel = document.createElement('SCRIPT');
jsel.type = 'text/javascript';
jsel.src = url

// Append JS element (therefore executing the the PHP call)
document.body.appendChild (jsel);

return true;
}

-------------
The PHP file that is called looks like this

<?php
include_once("./connect.inc.php");
// defines $database, $map_testC

$zip = $_GET['z'];
$sql = 'SELECT `cazZip` FROM `zips_CA` WHERE cazZip = ' . $zip;

$selected = mysql_select_db($database, $map_testC) ;
if ( !$selected ) {
$res = 'Not connected : ' . mysql_error();
} else {
$Result1 = mysql_query($sql, $map_testC) ;
if ( !$Result1 ) {
$res = 'No query : ' . mysql_error();
} else {
$res = mysql_num_rows($Result1);
}
}

?>
// a javascript function which sets text content of a DOM element
// use an inline PHP snippet to read the result string
setTextContent( getElementById_s('divZipCheckRes'),
"<?php echo $res; ?>" );
================================================== ======================
C- The Desired Result

I am attempting to dynamically update a page, based on local databases
in Main. I tried an experiment with XMLHttpRequest() earlier, but found
I was not able to call outside of my own domain without purchasing an
digital signature certificate from Verisign or someone. That led me down
the path of jsHack(), Dynamically Loaded Scripts. Due to the nature of
my problem, I believe I can preprocess any data I will need and rely on
local databases. I have put a large amount of effort into the jsHack()
approach. Since I have all the parts working and am just missing reading
the result from PHP back into Javascript, it seems like the right idiom
might finish the puzzle.

Also, I want to minimize the URL passing. Eventually there will be
data that the solution requires is not publicly visible and putting that
into the URL seems sloppy. Primarily though I am looking for the dynamic
page updates that are the mark of current browser software.

This is my first Javascript program so I am more than willing to
change the design approach as appropriate. I appreciate thoughful
comments or suggestions, and do appreciate the answers I have read on
USENET that let me get as far as I have.
Jan 22 '06 #19

P: n/a
one man army wrote:
In article <Au******************************@comcast.com>,
Randy Webb <Hi************@aol.com> wrote STUFF
The following describes three situations:
a) a javascript demo and its structure
b) the attempt at using JS/PHP, and what went wrong
c) the proposed finished product

================================================== ======================
A - A Demo Site in Javascript/CSS/HTML

There are two pages, lets call them Intro and Main. There is a single
Javascript core, which is shared by both pages by means of a script
include in the <HEAD>. The same JS functions are called in both Intro
page and Main page.
<script type="text/javascript" src="lHd.js" DEFER> </script>

The Intro page consists of a table with a form in its center. It is
named index.html. Along with sharp graphics and a logo, there is a
single INPUT, type=TEXT.
<input size="10" id="zipRaw_id" name="zipRaw_name">
(TEXT by default,apparently. I added TYPE later)

The form looks like this:

<form name="ZipEnterText" method="get"
onsubmit="return mainZipCheck()"
action="aBasicSearchResult.html" >
--
Javascript function mainZipCheck() {
var zipFld = null;

// use a cover func with compatability code
zipFld = getElementById_s( "zipRaw_id");
if ( zipFld == null ) return;
// do a simple RegEx check for digits
if ( false == checkZipValid( zipFld.value))
return false;

if ( false == lkupZip( zipFld.value)) {
window.alert( "Is that a valid California Zip Code?");
return false;
}

return true;
}
--
// (this is one of two places the SQL will come in later)
Javascript function lkupZip() {
uses a global called gzZip_DataSrc
a javascript data object loaded by rote with 3000 zip codes inline
search the gzZip_DataSrc
return found
}

function zipDataObj( inZip) { this.zdZip = inZip;}
function makeZipArray() {
var i = 0;
this[i++] = new zipDataObj( 90001 );
...
}
--
Intro page is complete. When mainZipCheck() return true, the browser
gets the url xxx/aBasicSearchResult.html?zipRaw_name="90000"

==========
Main Page
Upon entering the page, onLoad() checks for a URL with a tail. If
present, the tail is read for zipRaw_name. Call the same lkupZip() for
sanity check. This time, another global data object is initialized,
gaAddr_DataSrc the Addr object. Same rote javascript inline data
technique - the second place where SQL will be needed. The function take
the ZipStr, an Array that will be filled out with indexes into the
gaAddr_DataSrc, and returns the count of items found.
function doAddrSearch( inZipStr, ioResArray)

If addresses are found, a function is called to show the results on the
Main page.

On the Main page, there is a form in the sidebar with an identically
named input and a submit button. Additional criteria are there also,
which were defaulted from the intro page.
<form name="EnterData" method="get" onsubmit=" return mainZipCheck()">
<input size="10" id="zipRaw_id" name="zipRaw_name" maxlength="10" >

So when the submit button is pressed, the browser gets a new URL
xxx/aBasicSearchResult.html?zipRaw_name="90000" The Action apparently
defaults to the current page.

Main Page is complete.

================================================== ======================
B- What I tried and How it Went Wrong

I found by reading USENET and some web sites that there was a hack
that allowed a dynamic appending of a script element, which then
executes. By specifying that script element as Javascript, but calling
the file xxx.php, an arbitrary amount of JS/PHP can be executed, eg
Dynamically Loaded Scripts.

I created a MySQL database with a table of Zip Codes, and the PHP
snippet which calls the database and executes a simple query. I used
phpMyAdmin to load the database and create the query string.

In the Intro page I experimented with onSubmit() and the Action in the
form. I was having problems, so I added a button which simply called a
javascript function for testing purposes.

I intended to call PHP to do the query, then read the result back in
Javascript. Since I could not find a way of passing a PHP var into
something Javascript can read, I set the content of a hidden field to
the number of items found, or the error msg on SQL error.

This all worked. But in the next line of Javascript, upon returning
from the execution of the PHP via document.body.appendChild(
scriptElement), the result of the query was not there yet. Apparently
there is some kind of event loop or somesuch that queued the execution
of the PHP. The result was there visibly in the browser window, and on
inspection with the Firefox DOM inspector.

I do not know how to queue an event to chain calls in this
environment. So the Intro page failed, and I did not get to the Main
page.

The Javascript looks like this:

// jsHack Setup - Get base url
var url = document.location.href;
var xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);

var jsHack_get_error = false;

function introZipCheck()
{
var tUrlStr = 'zipLkUp.php';
// add ZipStr to URL for the PHP code
tUrlStr = tUrlStr + '?' + 'z=' + getElementById_s('zipRaw_id').value;

jsHack_do( tUrlStr );

// check return result in a hidden field
var elem = getElementById_s('divZipCheckRes');
if ( null == elem ) {
window.alert( "introZipCheck() - Problem finding result?");
return false;
}
var tNode = elem.firstChild;

if ( "1" != tNode.data) {
window.alert( tNode.data + " Is that a valid California Zip
Code?");
return false;
}

return true;
}

//----------------------------------------
function jsHack_do (url) {
// Does URL begin with http?
if (url.substring(0, 4) != 'http') {
url = base_url + url;
}

// Create new JS element
var jsel = document.createElement('SCRIPT');
jsel.type = 'text/javascript';
jsel.src = url

// Append JS element (therefore executing the the PHP call)
document.body.appendChild (jsel);

return true;
}

-------------
The PHP file that is called looks like this

<?php
include_once("./connect.inc.php");
// defines $database, $map_testC

$zip = $_GET['z'];
$sql = 'SELECT `cazZip` FROM `zips_CA` WHERE cazZip = ' . $zip;

$selected = mysql_select_db($database, $map_testC) ;
if ( !$selected ) {
$res = 'Not connected : ' . mysql_error();
} else {
$Result1 = mysql_query($sql, $map_testC) ;
if ( !$Result1 ) {
$res = 'No query : ' . mysql_error();
} else {
$res = mysql_num_rows($Result1);
}
}

?>
// a javascript function which sets text content of a DOM element
// use an inline PHP snippet to read the result string
setTextContent( getElementById_s('divZipCheckRes'),
"<?php echo $res; ?>" );
================================================== ======================
C- The Desired Result

I am attempting to dynamically update a page, based on local databases
in Main. I tried an experiment with XMLHttpRequest() earlier, but found
I was not able to call outside of my own domain without purchasing an
digital signature certificate from Verisign or someone. That led me down
the path of jsHack(), Dynamically Loaded Scripts. Due to the nature of
my problem, I believe I can preprocess any data I will need and rely on
local databases. I have put a large amount of effort into the jsHack()
approach. Since I have all the parts working and am just missing reading
the result from PHP back into Javascript, it seems like the right idiom
might finish the puzzle.

Also, I want to minimize the URL passing. Eventually there will be
data that the solution requires is not publicly visible and putting that
into the URL seems sloppy. Primarily though I am looking for the dynamic
page updates that are the mark of current browser software.

This is my first Javascript program so I am more than willing to
change the design approach as appropriate. I appreciate thoughful
comments or suggestions, and do appreciate the answers I have read on
USENET that let me get as far as I have.


OK, your problem is you can't do what you want.

PHP is server side; javascript is client side. All PHP code is
processed before the page is sent to the browser; all Javascript code is
processed after the page gets to the browser.

PHP can generate Javascript code (just like it does HTML), but it can't
call Javascript.

And the only way you can "call" a PHP script from javascript is to load
a page (current or new) containing php code.

Also, PHP would not have queued the request. You must have another problem.

If you want to update one field with JS based on the contents of another
field, you'll have to pass all the information required, probably in a
hidden field. The other alternative is to submit the page back to
itself and reprocess the data to generate the output you desire.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jan 23 '06 #20

P: n/a
On 2006-01-22, one man army <ne****@screenlightDOT.com> wrote:
B- What I tried and How it Went Wrong

I found by reading USENET and some web sites that there was a hack
that allowed a dynamic appending of a script element, which then
executes. By specifying that script element as Javascript, but calling
the file xxx.php, an arbitrary amount of JS/PHP can be executed, eg
Dynamically Loaded Scripts.
yes.
I created a MySQL database with a table of Zip Codes, and the PHP
snippet which calls the database and executes a simple query. I used
phpMyAdmin to load the database and create the query string.

In the Intro page I experimented with onSubmit() and the Action in the
form. I was having problems, so I added a button which simply called a
javascript function for testing purposes.

I intended to call PHP to do the query, then read the result back in
Javascript. Since I could not find a way of passing a PHP var into
something Javascript can read, I set the content of a hidden field to
the number of items found, or the error msg on SQL error.

This all worked. But in the next line of Javascript, upon returning
from the execution of the PHP via document.body.appendChild(
scriptElement)
this is faulty thinking it is not a procedure call, in javascript you
are downloading a file and appending, it to the document and executing
it.
, the result of the query was not there yet. Apparently
there is some kind of event loop or somesuch that queued the execution
of the PHP. The result was there visibly in the browser window, and on
inspection with the Firefox DOM inspector.
I'n not sure what you mean by event loop, yes the result it not there
immediately but will arrive soon (depending on network etc...)

AIUI the object has an onload property that can be used to activate code
after it has loaded (and executed) basically this is like any other event
handler....

This means you can't reliably do a synchronous request, your script must run
in two parts, one to request the result and a further part to handle the
result.

there's a different handler if it fails but I forget the name
This is my first Javascript program so I am more than willing to
change the design approach as appropriate. I appreciate thoughful
comments or suggestions, and do appreciate the answers I have read on
USENET that let me get as far as I have.


basically you need to saw it in half and have one half making requests and
the other half handling the responses.

Bye.
Jasen
Jan 23 '06 #21

P: n/a
In article <6a*****************@clunker.homenet>,
Jasen Betts <ja***@free.net.nz> wrote:
On 2006-01-22, one man army <ne****@screenlightDOT.com> wrote:
B- What I tried and How it Went Wrong

I found by reading USENET and some web sites that there was a hack
that allowed a dynamic appending of a script element, which then
executes. By specifying that script element as Javascript, but calling
the file xxx.php, an arbitrary amount of JS/PHP can be executed, eg
Dynamically Loaded Scripts.


yes.
I created a MySQL database with a table of Zip Codes, and the PHP
snippet which calls the database and executes a simple query. I used
phpMyAdmin to load the database and create the query string.

In the Intro page I experimented with onSubmit() and the Action in the
form. I was having problems, so I added a button which simply called a
javascript function for testing purposes.

I intended to call PHP to do the query, then read the result back in
Javascript. Since I could not find a way of passing a PHP var into
something Javascript can read, I set the content of a hidden field to
the number of items found, or the error msg on SQL error.

This all worked. But in the next line of Javascript, upon returning
from the execution of the PHP via document.body.appendChild(
scriptElement)


this is faulty thinking it is not a procedure call, in javascript you
are downloading a file and appending, it to the document and executing
it.
, the result of the query was not there yet. Apparently
there is some kind of event loop or somesuch that queued the execution
of the PHP. The result was there visibly in the browser window, and on
inspection with the Firefox DOM inspector.


I'n not sure what you mean by event loop, yes the result it not there
immediately but will arrive soon (depending on network etc...)

AIUI the object has an onload property that can be used to activate code
after it has loaded (and executed) basically this is like any other event
handler....

This means you can't reliably do a synchronous request, your script must run
in two parts, one to request the result and a further part to handle the
result.

there's a different handler if it fails but I forget the name
This is my first Javascript program so I am more than willing to
change the design approach as appropriate. I appreciate thoughful
comments or suggestions, and do appreciate the answers I have read on
USENET that let me get as far as I have.


basically you need to saw it in half and have one half making requests and
the other half handling the responses.

Bye.
Jasen


thanks Jasen! thats what I am looking for.
BUT the book I am looking at says that the onload() handler for a SCRIPT
element is a Microsoft extension, not DOM spec. I need to work with
Firefox. ;-)

Can I do a ScriptElem.setAttribute() and attach an onload() handler?
(I'm reaching here...)

I am trying to check the DOM level 2 ref at
http://www.w3.org/TR/2000/REC-DOM-Le...1113/core.html

but its really hard to read.

This is getting warmer.
Jan 23 '06 #22

P: n/a
In article <6a*****************@clunker.homenet>,
Jasen Betts <ja***@free.net.nz> wrote:

there's a different handler if it fails but I forget the name
...
basically you need to saw it in half and have one half making requests and
the other half handling the responses.

Might that be a Mutation event?
I found an example of adding an event listener that then watches for a
Mutation event. http://webservices.xml.com/2004/01/0.../Listing7.html

I'm willing to start down that path if that is the way to go...
Jan 24 '06 #23

P: n/a
In article <6a*****************@clunker.homenet>,
Jasen Betts <ja***@free.net.nz> wrote:
, the result of the query was not there yet. Apparently
there is some kind of event loop or somesuch that queued the execution
of the PHP. The result was there visibly in the browser window, and on
inspection with the Firefox DOM inspector.


I'n not sure what you mean by event loop, yes the result it not there
immediately but will arrive soon (depending on network etc...)

AIUI the object has an onload property that can be used to activate code
after it has loaded (and executed) basically this is like any other event
handler....

This means you can't reliably do a synchronous request, your script must run
in two parts, one to request the result and a further part to handle the
result.

there's a different handler if it fails but I forget the name
This is my first Javascript program so I am more than willing to
change the design approach as appropriate. I appreciate thoughful
comments or suggestions, and do appreciate the answers I have read on
USENET that let me get as far as I have.


basically you need to saw it in half and have one half making requests and
the other half handling the responses.


I also just found the Javascript setTimeOut() call, though in this
book its listed as not being part of DOM. Better than a Mutation event
handler?

In other words, After setting off a PHP/JS snippet using
document.body.appendChild(), the last line sets up a one off function
call using setTimeOut() to look for the response, which is set into the
document somewhere in a pre-arranged element, for example a hidden INPUT.
Jan 24 '06 #24

P: n/a
thanks Jasen! thats what I am looking for.
BUT the book I am looking at says that the onload() handler for a SCRIPT
element is a Microsoft extension, not DOM spec. I need to work with
Firefox. ;-)
firefox supports it too, (well mozilla did last month... when I tried it)
onreadystatechange is an IE extension and is IE only.
Can I do a ScriptElem.setAttribute() and attach an onload() handler?
You don't need setAttribute,

ScriptElem.onload=onLoadFunction;

having previously done

function onLoadFunction(){ /* your code here */ }

or similar
I am trying to check the DOM level 2 ref at
http://www.w3.org/TR/2000/REC-DOM-Le...1113/core.html

but its really hard to read.


I wasn't aware that dynamically loading script was actually covered by the
standard.

This code works in mozilla:

function pastejs(url,onloadfunc){
var s = document.createElement("script");
s.onload=onloadfunc;
s.type = "text/javascript";
s.src = url;
document.body.appendChild(s);
}

Bye.
Jasen
Jan 24 '06 #25

P: n/a
one man army said the following on 1/22/2006 3:18 PM:
In article <Au******************************@comcast.com>,
Randy Webb <Hi************@aol.com> wrote STUFF
I don't recall writing "STUFF" but if you say so.

The following describes three situations:
a) a javascript demo and its structure
I gave you a URL to a demo. The only difference in what I pointed you to
and what you are doing is how the .js files get generated. The page I
pointed you to has static .js files but they could just as easily be
dynamically generated .js files that are generated by PHP.
b) the attempt at using JS/PHP, and what went wrong
<snip>

================================================== ======================
B- What I tried and How it Went Wrong

I found by reading USENET and some web sites that there was a hack
that allowed a dynamic appending of a script element, which then
executes. By specifying that script element as Javascript, but calling
the file xxx.php, an arbitrary amount of JS/PHP can be executed, eg
Dynamically Loaded Scripts.
Yes, even if it is static .js files. That is the entire concept/idea
behind dynamically loading them. And, it enjoys wider support than
XMLHTTPReqquest does.
I created a MySQL database with a table of Zip Codes, and the PHP
snippet which calls the database and executes a simple query. I used
phpMyAdmin to load the database and create the query string.
And did that query return valid JS Code?
In the Intro page I experimented with onSubmit() and the Action in the
form. I was having problems, so I added a button which simply called a
javascript function for testing purposes.

I intended to call PHP to do the query, then read the result back in
Javascript. Since I could not find a way of passing a PHP var into
something Javascript can read, I set the content of a hidden field to
the number of items found, or the error msg on SQL error.
I showed you how to pass the variable to PHP from JS and then how to
load the file dynamically and execute the JS in it.
This all worked. But in the next line of Javascript, upon returning
from the execution of the PHP via document.body.appendChild(
scriptElement), the result of the query was not there yet. Apparently
there is some kind of event loop or somesuch that queued the execution
of the PHP. The result was there visibly in the browser window, and on
inspection with the Firefox DOM inspector.
That is a timing issue with regards to the time it takes to download the
..js file. That is why I suggested to you to put the function call at the
end of the .js file and execute it from there.
<snip>
================================================== ======================
C- The Desired Result

I am attempting to dynamically update a page, based on local databases
in Main. I tried an experiment with XMLHttpRequest() earlier, but found
I was not able to call outside of my own domain without purchasing an
digital signature certificate from Verisign or someone. That led me down
the path of jsHack(), Dynamically Loaded Scripts. Due to the nature of
my problem, I believe I can preprocess any data I will need and rely on
local databases. I have put a large amount of effort into the jsHack()
approach. Since I have all the parts working and am just missing reading
the result from PHP back into Javascript, it seems like the right idiom
might finish the puzzle.
Re-read this entire thread with regards to your posts and mine. I don't
want to have to re-post it all but the answer was posted.
Also, I want to minimize the URL passing. Eventually there will be
data that the solution requires is not publicly visible and putting that
into the URL seems sloppy. Primarily though I am looking for the dynamic
page updates that are the mark of current browser software.
With loading JS Files on the fly, the URL's that you use will never be
seen by the user unless you are using different pages and navigating in
the browser.
This is my first Javascript program so I am more than willing to
change the design approach as appropriate. I appreciate thoughful
comments or suggestions, and do appreciate the answers I have read on
USENET that let me get as far as I have.


You have a good design approach, but stick with it. Don't get
discouraged and do a lot of reading :)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 24 '06 #26

P: n/a
["Followup-To:" header set to comp.lang.javascript.]
On 2006-01-24, one man army <ne****@screenlightDOT.com> wrote:
In article <6a*****************@clunker.homenet>,
Jasen Betts <ja***@free.net.nz> wrote:

there's a different handler if it fails but I forget the name
...
basically you need to saw it in half and have one half making requests and
the other half handling the responses.
Might that be a Mutation event?


onerror
I found an example of adding an event listener that then watches for a
Mutation event. http://webservices.xml.com/2004/01/0.../Listing7.html


that listing doesn't look like javascript to me.
(mainly it uses import and class which is not allowed in javascript)

Bye.
Jasen
Jan 25 '06 #27

P: n/a
I'm setting "Followup-To: comp.lang.javascript" as this thread has moved away
from PHP.

On 2006-01-24, one man army <ne****@screenlightDOT.com> wrote:
In article <6a*****************@clunker.homenet>,
Jasen Betts <ja***@free.net.nz> wrote:
basically you need to saw it in half and have one half making requests and
the other half handling the responses.


I also just found the Javascript setTimeOut() call, though in this
book its listed as not being part of DOM. Better than a Mutation event
handler?


the easiest way to "communicate from the loaded script to the master" is by
either calling a public function or creating or modifying a public variable

or onload can be used by the master to be informed when it has loaded...
when it loads its content becomes part of the javascript environment, etc...
Bye.
Jasen
Jan 25 '06 #28

This discussion thread is closed

Replies have been disabled for this discussion.