NYCPHP Meetup

NYPHP.org

[nycphp-talk] Passing JAVASCRIPT variables to PHP

tedd tedd at sperling.com
Tue Apr 1 09:22:20 EDT 2008


At 3:51 PM -0700 3/31/08, Susan Shemin wrote:
>Just as this question came up here, I was again researching it on 
>the internet, and very clearly saw that the crux of the problem is 
>that Javascript is client side and PHP server side, meaning the 2 
>don't mix unless in Ajax.

They mix Okay, but don't communicate well without effort.

The reason for this is simple -- just before a web page is delivered 
to a users browser all of php's work is done and as the web page 
loads in the browser, then javascript's work starts.

Communication between the two languages is a question of timing.

Ajax is simply javascript sending data (via POST or GET) to a slave 
php script, which in turn provides data back to the web page without 
the need for a refresh.

The communication is exactly the same as if you were using a form 
minus the refresh.

The problem, of course, is that javascript has security issues and 
some users would rather have a refresh than risk security.

Javascript and php can play well together as this demonstrates:

http://webbytedd.com/b/timed-php/

But, it's not simple.  :-)

Cheers,

tedd

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the talk mailing list