is there any way to make php and javascript talk?

Any problem with PHP can be disscused here
Lixas
Posts: 750
Joined: Wed Feb 16, 2005 4:21 pm

Post by Lixas »

when developing sites, sometimes we need to get some of variables, like users screen resolution and others. PHP can not obtain screen resolution, but you can do this with javascript. and the main thread's idea is how to pass variable from javascript to php!
Did you get dat ?


Image
uz
Posts: 140
Joined: Sat Dec 24, 2005 5:32 pm

Post by uz »

kaos can we have a look to ur site?
iPod Wizard
Posts: 987
Joined: Sun Feb 26, 2006 4:56 pm
Contact:

Post by iPod Wizard »

Its in his profile...whoa its weird...searching stuff...
skyline_music
Posts: 31
Joined: Thu Mar 23, 2006 6:51 am

Post by skyline_music »

The simplest answer I can concieve to this question is as follows:

PHP is initialised before the page is load, and writes it's own code (HTML) into the page.
Therefore, if you include JavaScript code in an echo or a variable that becomes part of the HTML source for the page, that JavaScript will become active once the page has loaded.

Like kaos said, one is active only while the other is inactive, however, that does not mean that code from one cannot **** code in another. I.e. if you have a JavaScript where the code requires a variable x, then you can have PHP determine what the value of x is before the JavaScript is loaded. :twisted:
uz
Posts: 140
Joined: Sat Dec 24, 2005 5:32 pm

Post by uz »

why do u need that?
redwall_hp
Posts: 24
Joined: Thu Jun 01, 2006 3:22 pm

Post by redwall_hp »

You know thev way you can go www.mydomain.com/index.php?var="value"? Javascript can set/read the stuff after the question mark, too. Look on google for more info on how to do it.
mohumben
Posts: 82
Joined: Thu Sep 15, 2005 9:45 pm

Post by mohumben »

I use an invisible iframe (0x0) that can be used to "AJAX-like" functions.

JS can be used to POST / GET and making it "talk" with PHP is like making the user "talk" with PHP

Code: Select all

define('I_LOVE_PHP', true);
Post Reply