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