Re: [PHP] php - js (was Javascript Navigation)

2006-04-29 Thread Richard Lynch
On Thu, April 27, 2006 6:39 pm, tedd wrote:
 At 1:57 PM -0700 4/27/06, Paul Novitski wrote:
 variable to js and will cause js to execute. But, isn't there
 anything else? Is that all there is?

That's all there is unless  you really want to chew up all your HTTP
connctions with a hell of a lot of useless information going
back-and-forth...

You could get an ongoing dialog going with PHP and JS as you have done
with AJAX, and you could even get the two of them to send each other
specific messages you would make up that would make the other one poll
back for more info...

But that would be incredibly wasteful.

If you need that kind of real-time client-server interaction, you should:

A) Switch to Java which kinda sorta has a working keep-alive
applet/servelet model.

B) Write a custom client-server application.

But trying to force JS - PHP communication the way you are
describing it is only going to make you very unhappy in the long run.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php - js (was Javascript Navigation)

2006-04-29 Thread tedd

At 4:54 AM -0500 4/29/06, Richard Lynch wrote:


But trying to force JS - PHP communication the way you are
describing it is only going to make you very unhappy in the long run.


Been to that dance more than once. But, as Dirty Harry once said A 
man's got to know his limitations.


Thanks for all your help -- you guys have been super.

tedd
--

http://sperling.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php - js (was Javascript Navigation)

2006-04-28 Thread tedd

At 5:54 PM -0700 4/27/06, Paul Novitski wrote:

At 04:39 PM 4/27/2006, tedd wrote:
What I don't get is how php can pass variables to js and cause it 
to run at will.


Do you mean the way one function can call another function within 
the same program?


No, I realize that php are two different language on two different 
computers sharing one event.


It sounds like you're picturing PHP  JavaScript executing 
continuously  simultaneously.  You aren't, are you?


Not simultaneously and/or continuously but an easy way to communicate 
with each other.


JavaScript can execute a PHP program at will simply by requesting 
a PHP page from the server.  PHP can execute a JavaScript function 
at will simply by downloading it (with at least minimal HTML 
markup) to a browser.


That seems pretty simple  direct to me, considering that they're 
running in different computers.


What's simple and direct to you may not be to others -- and I fully 
realize that both environments are running on different computers at 
different times -- it's the your perspective of at will I need to 
come to terms with.


I can see how php can, and have used php to, generate a web page 
which has body onload=js() tag, which can pass a variable to js 
and will cause js to execute. But, isn't there anything else? Is 
that all there is?

...
I also understand that php can generate html (have done it) and 
echo out javascript that may, or may not, run if js is present -- 
like Robert suggested in his WAHOOEY (LOL) example. But, that 
appears messy to me. If php wants to say something to js, then a 
page must be created -- it seems like a lot foreplay to get at the 
goodies.


Without a downloaded page, what goodies are there?

You know, you can download pure JavaScript, dressed only in a script 
tag, to a browser and have it execute without carrying with it a 
whole HTML page.  Is that what you're looking for?  What would such 
a script accomplish that a PHP program couldn't?  I suppose it could 
interact with the human user with prompts, alerts, and confirms; 
gather information about the client such as monitor  window size; 
grab local time to compare to server time.  What else?  If it has to 
create DOM nodes to interact with the user, haven't you come full 
circle and shouldn't you just download an HTML page to be 
JavaScript's environment?




I guess what I'm looking for is something simpler -- is there?


Paint me a picture of a hypothetical simpler situation; I'm intrigued.


I think you have provided me with a clearer picture of what's going 
on and some things for me to consider. I need to pound some code.


Thanks for your time and insight.

tedd
--

http://sperling.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php - js (was Javascript Navigation)

2006-04-27 Thread Paul Novitski

At 08:03 AM 4/27/2006, tedd wrote:
Forgive me my simplicity, but trying to tie communication between 
php with javascript is like trying to get the past and future to 
talk to each other -- they exist at different times. Normally, php 
is history when js steps on the stage and while js may say a few 
lines to php (i.e., Alas Poor Yorrick, I Knew Him ...), there isn't 
any real dialog.


Additionally, with regard to the web, their activations are 
different. JS listens and responds to user activities whereas php 
only responds to a limited set of prompts.


Ajax appears to blur the distinction somewhat, but it's still 
nothing more than a call from js to php and js has no idea if php's 
task was successful, or not. In other words, there is no real 
two-way communication.


To me, what's needed to combine these two languages successfully is 
simply communication, such as:


1. A way to send information from js to php and have php act upon it.

2. A way to send information from php to js and have js act upon it.

Then one of the two languages (most likely js) would need to have 
some sort of repeating polling mechanism where instructions could be 
handled -- an event loop.



But Tedd, this is how so many web applications work now:  PHP 
generates pages in which and on which JavaScript acts, and JavaScript 
helps direct to URLS, forms querystrings, and post form input back to 
the server.


It's true that PHP can't know whether JavaScript will be running in 
the next page it delivers, so it has to generate pages that will be 
fully functional even if there's no one to talk to.  It's easy to 
build in semaphores that let PHP know whether or not JavaScript was 
running in the page last posted, although as we know it should 
validate all the incoming data and not DEPEND on client-side 
scripting for anything.


It's true that part of JavaScript's mandate is real-time user 
interaction which PHP can't touch, and part of PHP's mandate is file 
manipulation that JavaScript can't perform.  So what?  It's 
commonplace for different components of a complex system to have 
discrete functional domains.  For what it's worth the two languages 
also share capabilities, such as creating and manipulating document 
elements, strings, and arithmetic calculations.  The fact that their 
domains aren't identical is hardly a show-killer.



To me, what's needed to combine these two languages successfully is 
simply communication, such as:


1. A way to send information from js to php and have php act upon it.


URL, querystring, form input, and cookies.



2. A way to send information from php to js and have js act upon it.


HTML, inline script blocks, dynamic script files, and cookies.


I believe you're seeing monsters in the closet where there are only 
rumpled socks.


Warm regards,
Paul  


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php - js (was Javascript Navigation)

2006-04-27 Thread tedd

At 9:18 AM -0700 4/27/06, Paul Novitski wrote:

I believe you're seeing monsters in the closet where there are only 
rumpled socks.


I'm not trying to see, or create monsters, I'm just trying to understand.

To me, what's needed to combine these two languages successfully is 
simply communication, such as:


1. A way to send information from js to php and have php act upon it.


URL, querystring, form input, and cookies.


Okay, I understand how js and html can communicate with php -- but, 
that's not the problem. My statement above was part of a symmetrical 
requirement regarding communication.



2. A way to send information from php to js and have js act upon it.


HTML, inline script blocks, dynamic script files, and cookies.


But, show me an example of php doing each of the above where js will 
receive the data and will act upon it.


For example, if php creates a cookie, then how does js know that? How 
can the presence of a cookie cause js to run?


Can js cycle reading cookies waiting for something to do while php 
crons writing them as needed -- and vise-versa? Is that a viable 
method of communication and activation between the two?


Is there anything that php can do that will initiate a js routine? As 
far as I know (limited as I am) php can't even detect if js is 
present, or not, let alone cause a javascript routine to run -- is 
that not correct? If not, please give me an example of where php can 
make js run.


Thanks.

tedd

--

http://sperling.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php - js (was Javascript Navigation)

2006-04-27 Thread Robert Cummings
On Thu, 2006-04-27 at 13:33, tedd wrote:
 At 9:18 AM -0700 4/27/06, Paul Novitski wrote:

 Okay, I understand how js and html can communicate with php -- but, 
 that's not the problem. My statement above was part of a symmetrical 
 requirement regarding communication.

Communication need not be symmetrical. All that is required is that each
end understand one another.

 2. A way to send information from php to js and have js act upon it.
 
 HTML, inline script blocks, dynamic script files, and cookies.
 
 But, show me an example of php doing each of the above where js will 
 receive the data and will act upon it.

See google maps or google suggest for excellent examples.

 For example, if php creates a cookie, then how does js know that? How 
 can the presence of a cookie cause js to run?

JS I do believe has access to the cookie. Either way, PHP is perfectly
cable of informing JS of the cookie.

 Can js cycle reading cookies waiting for something to do while php 
 crons writing them as needed -- and vise-versa? Is that a viable 
 method of communication and activation between the two?

Js can cycle, I don't suggest a while loop, it is better to use the
system timer to do periodic polling.

 Is there anything that php can do that will initiate a js routine? As 

Yes:

echo WAHOOEY

html
script language=javascript type=text/javascript
goBabyGo();
/script
body onLoad=goBabyGo()
Why are you staring at me?
/body
/html

WAHOOEY;

 far as I know (limited as I am) php can't even detect if js is 
 present, or not, let alone cause a javascript routine to run -- is 
 that not correct? If not, please give me an example of where php can 
 make js run.

You're thinking is erroneous. PHP can indeed detect if JavaScript is
present. And as shown above it can cause a JavaScript routine to run. If
someone disable's JavaScript, that is not the problem of PHP, that is
akin to trying to run MS Winblows binaries under linux or vice versa --
the environment must be sane for the program to run.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php - js (was Javascript Navigation)

2006-04-27 Thread Paul Novitski

At 10:33 AM 4/27/2006, tedd wrote:

At 9:18 AM -0700 4/27/06, Paul Novitski wrote:

I believe you're seeing monsters in the closet where there are only 
rumpled socks.


I'm not trying to see, or create monsters, I'm just trying to understand.


Sorry, that was my attempt to be light-hearted and disarming~

Tedd, it almost seems as though one of your requirements for 
PHP-JavaScript communication is that there be PHP and JS scripts 
running continuously trading bits of information back and forth.  The 
web model is quite different, with scripts starting up and ending 
with each page-load.  A full-page round-trip to the server, as when 
you click on a hyperlink or submit a form, is one complete cycle of 
client-server communication.  It is possible to trigger smaller 
increments of communication as Ajax/XMLHttpRequest demonstrates, but 
still each time you talk to the server you're starting a PHP script 
running from scratch on the server.  This wake up/go to sleep model 
doesn't disqualify it, in my view, from constituting communication 
between two scripts.



To me, what's needed to combine these two languages successfully 
is simply communication, such as:


1. A way to send information from js to php and have php act upon it.


URL, querystring, form input, and cookies.


Okay, I understand how js and html can communicate with php -- but, 
that's not the problem. My statement above was part of a symmetrical 
requirement regarding communication.


Sorry -- symmetrical?  Please elucidate, I'm not familiar with this 
term in this context.  Which factors need to be the same on both 
sides of the Turing box lid for your criteria to be satisfied?




2. A way to send information from php to js and have js act upon it.


HTML, inline script blocks, dynamic script files, and cookies.


But, show me an example of php doing each of the above where js will 
receive the data and will act upon it.


Well, first of all, JavaScript acts in the context of an HTML 
page.  When PHP generates the page, PHP is providing JS with all the 
elements and attributes necessary to conduct its business.  If 
JavaScript submits a form with particular input name/value pairs, PHP 
can respond by selecting data from a table and/or branching in its 
logic tree and generating a particular set of markup on the next page 
for JavaScript to operate on.


PHP can output HTML markup containing data for JavaScript to operate on.

PHP can output script blocks into an HTML document containing 
executable instructions including static and array variable definitions.


PHP can dynamically supply external JavaScript files, literally 
cooking the JS scripting logic from server-side.



For example, if php creates a cookie, then how does js know that? 
How can the presence of a cookie cause js to run?


Gecko DOM Reference
DOM:document.cookie
http://developer.mozilla.org/en/docs/DOM:document.cookie

Also google javascript cookie e.g. 
http://www.netspade.com/articles/2005/11/16/javascript-cookies/



Can js cycle reading cookies waiting for something to do while php 
crons writing them as needed -- and vise-versa? Is that a viable 
method of communication and activation between the two?


No, because cookie values are changed only on page submit  load.

To my knowledge, XMLHttpRequest is the only way for JavaScript to 
request  receive PHP data during a single page-view.  (Well, there 
is another way: JavaScript can create an Image object on the fly with 
a PHP script as the SRC and data on the quesrystring, but I haven't 
taken the trouble to cook up a scheme for PHP to deliver and 
JavaScript to extract information from an image bitstream so in my 
work this is a one-way communication channel.)   This demonstrates 
that a single, continuously-executing JavaScript program can wait for 
responses from the server.  The opposite is clearly true in principle 
-- the server's operating system waits for the next HTTP request from 
the client -- although I suspect that it would be excessively and 
unnecessarily burdensome on the server to have a PHP script continue 
to execute in anticipation of the next client request.  Much more 
efficient to have the operating system wake up the PHP interpreter 
and execute a script only when one flies in the window.



Is there anything that php can do that will initiate a js routine? 
As far as I know (limited as I am) php can't even detect if js is 
present, or not, let alone cause a javascript routine to run -- is 
that not correct? If not, please give me an example of where php can 
make js run.


PHP can initiate JavaScript execution simply by downloading an HTML 
page that contains JS script set to execute immediately or on a given 
event.  Every time JavaScript runs in a page generated by PHP, PHP is 
essentially telling the JavaScript interpreter in the browser to 
execute the contained or linked script.  PHP can select a particular 
JS function to execute based on various criteria by downloading code 
to 

Re: [PHP] php - js (was Javascript Navigation)

2006-04-27 Thread Paul Novitski



At 10:33 AM 4/27/2006, tedd wrote:
Can js cycle reading cookies waiting for something to do while php 
crons writing them as needed -- and vise-versa? Is that a viable 
method of communication and activation between the two?


At 01:57 PM 4/27/2006, Paul Novitski wrote:

No, because cookie values are changed only on page submit  load.



Let me re-answer that.  Yes, cookies are an acceptable method of 
PHP-JavaScript communication -- when they're turned on in the client 
-- but require a new page load to synchronize changed values between 
client  server.


When I said no all I meant was that cookies don't work for 
communicating PHP-to-JavaScript within a single page-view.


Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php - js (was Javascript Navigation)

2006-04-27 Thread tedd

At 1:57 PM -0700 4/27/06, Paul Novitski wrote:

Okay, I understand how js and html can communicate with php -- but, 
that's not the problem. My statement above was part of a 
symmetrical requirement regarding communication.


Sorry -- symmetrical?  Please elucidate, I'm not familiar with 
this term in this context.  Which factors need to be the same on 
both sides of the Turing box lid for your criteria to be satisfied?


And

At 3:16 PM -0400 4/27/06, Robert Cummings wrote:


Communication need not be symmetrical. All that is required is that each
end understand one another.


Arrr...  my head hurts   :-)

Okay, a little misunderstanding here.

In my statement of symmetrical requirements regarding communication I 
basically said:


1. js - php
2. php - js

I was simply using symmetrical *statements* to illustrate my point. I 
was not implying a requirement that all communications must be 
symmetrical, understand?


Now, I know [1] that js can pass variables to php and cause it to run 
-- I do that using ajax -- that's not a problem.


What I don't get is how php can pass variables to js and cause it to 
run at will. I can see how php can, and have used php to, generate 
a web page which has body onload=js() tag, which can pass a 
variable to js and will cause js to execute. But, isn't there 
anything else? Is that all there is?


Paul you said:

All this seems very obvious to me, but knowing your level of 
sophistication with programming I'm led to suspect that perhaps I'm 
not understanding your question properly.


Thanks for the compliment, but I can be as dumb as a post about 
things until I fully understand them. However, everything you said I 
understand.


I understand that XMLHttpRequest works -- I'm a little fuzzy about 
how -- but, I have used it to both send data to php and to cause php 
to execute. That's not a problem.


I also understand that php can generate html (have done it) and echo 
out javascript that may, or may not, run if js is present -- like 
Robert suggested in his WAHOOEY (LOL) example. But, that appears 
messy to me. If php wants to say something to js, then a page must be 
created -- it seems like a lot foreplay to get at the goodies.


I guess what I'm looking for is something simpler -- is there?


tedd

PS: WAHOOEY indeed -- LOL, I'm still chuckling about that.
--

http://sperling.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php - js (was Javascript Navigation)

2006-04-27 Thread Robert Cummings
On Thu, 2006-04-27 at 19:39, tedd wrote:
 At 1:57 PM -0700 4/27/06, Paul Novitski wrote:
 
 Okay, I understand how js and html can communicate with php -- but, 
 that's not the problem. My statement above was part of a 
 symmetrical requirement regarding communication.
 
 Sorry -- symmetrical?  Please elucidate, I'm not familiar with 
 this term in this context.  Which factors need to be the same on 
 both sides of the Turing box lid for your criteria to be satisfied?
 
 And
 
 At 3:16 PM -0400 4/27/06, Robert Cummings wrote:
 
 Communication need not be symmetrical. All that is required is that each
 end understand one another.
 
 Arrr...  my head hurts   :-)
 
 Okay, a little misunderstanding here.
 
 In my statement of symmetrical requirements regarding communication I 
 basically said:
 
 1. js - php
 2. php - js
 
 I was simply using symmetrical *statements* to illustrate my point. I 
 was not implying a requirement that all communications must be 
 symmetrical, understand?
 
 Now, I know [1] that js can pass variables to php and cause it to run 
 -- I do that using ajax -- that's not a problem.
 
 What I don't get is how php can pass variables to js and cause it to 
 run at will. I can see how php can, and have used php to, generate 
 a web page which has body onload=js() tag, which can pass a 
 variable to js and will cause js to execute. But, isn't there 
 anything else? Is that all there is?
 
 Paul you said:
 
 All this seems very obvious to me, but knowing your level of 
 sophistication with programming I'm led to suspect that perhaps I'm 
 not understanding your question properly.
 
 Thanks for the compliment, but I can be as dumb as a post about 
 things until I fully understand them. However, everything you said I 
 understand.
 
 I understand that XMLHttpRequest works -- I'm a little fuzzy about 
 how -- but, I have used it to both send data to php and to cause php 
 to execute. That's not a problem.
 
 I also understand that php can generate html (have done it) and echo 
 out javascript that may, or may not, run if js is present -- like 
 Robert suggested in his WAHOOEY (LOL) example. But, that appears 
 messy to me. If php wants to say something to js, then a page must be 
 created -- it seems like a lot foreplay to get at the goodies.
 
 I guess what I'm looking for is something simpler -- is there?

There isn't something simpler, but that is necessitated by the stateless
nature of the web, and the security requirements of the client (the poor
sucker browsing the net :) I understand your desire for the simplicity
of a desktop application, but anonymous data sources and trust aren't
usually compatible. In the web paradigm the both the user and the server
need to distrust one another by default which isn't the case for bought
from a reputable, honest to goodness real live person, manually
installed desktop application *grin*. Although, can't say I trust MS
much.

 PS: WAHOOEY indeed -- LOL, I'm still chuckling about that.

It was nice of PHP to let us name our heredoc delimiters. I guess the
standard is EOF, but why write boring code ;)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php - js (was Javascript Navigation)

2006-04-27 Thread Paul Novitski

At 04:39 PM 4/27/2006, tedd wrote:
What I don't get is how php can pass variables to js and cause it to 
run at will.


Do you mean the way one function can call another function within the 
same program?


It sounds like you're picturing PHP  JavaScript executing 
continuously  simultaneously.  You aren't, are you?


JavaScript can execute a PHP program at will simply by requesting a 
PHP page from the server.  PHP can execute a JavaScript function at 
will simply by downloading it (with at least minimal HTML markup) to 
a browser.


That seems pretty simple  direct to me, considering that they're 
running in different computers.



I can see how php can, and have used php to, generate a web page 
which has body onload=js() tag, which can pass a variable to js 
and will cause js to execute. But, isn't there anything else? Is 
that all there is?

...
I also understand that php can generate html (have done it) and echo 
out javascript that may, or may not, run if js is present -- like 
Robert suggested in his WAHOOEY (LOL) example. But, that appears 
messy to me. If php wants to say something to js, then a page must 
be created -- it seems like a lot foreplay to get at the goodies.


Without a downloaded page, what goodies are there?

You know, you can download pure JavaScript, dressed only in a script 
tag, to a browser and have it execute without carrying with it a 
whole HTML page.  Is that what you're looking for?  What would such a 
script accomplish that a PHP program couldn't?  I suppose it could 
interact with the human user with prompts, alerts, and confirms; 
gather information about the client such as monitor  window size; 
grab local time to compare to server time.  What else?  If it has to 
create DOM nodes to interact with the user, haven't you come full 
circle and shouldn't you just download an HTML page to be 
JavaScript's environment?




I guess what I'm looking for is something simpler -- is there?


Paint me a picture of a hypothetical simpler situation; I'm intrigued.

Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php