Re: php <-> js (was Javascript Navigation)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux