On 4 April 2011 12:12, Jay Blanchard <jblanch...@pocket.com> wrote:
> So all of the pages I generate with PHP that call JavaScript functions
> and libraries are doing it wrong?

Short answer : yes.
Medium answer : probably, but really yes.
Long answer : unless you are providing some sort of mechanism to hold
the current state of PHP, eject the required JS code to get a value
from the client and return it to the server which then recreates the
working environment and carries on execution (try debugging THAT),
then almost certainly.

Under normal circumstances, the PHP code is completely finished
running before anything gets to the client. There is no mechanism for
allowing _this_ script to get a response to a JS call whilst running.

It is like the game of "pass the parcel". Your job (as in the PHP
script) is to unwrap 1 layer of paper and pass it on. That's it. PHP
runs and builds the appropriate output in response to the request that
the server directed to the PHP handler. Once the output has been
passed to the server, the PHP script is finished.

Whilst building the output, PHP cannot talk to the client. At the most
fundamental level, the client (the browser) is not listening for
anyone other than a response to the request it made to the server.

Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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

Reply via email to