Re[2]: [PHP] is it possible to communicate javascript and php?

From: Date: Wed, 24 Jan 2001 00:36:38 +0000
Subject: Re[2]: [PHP] is it possible to communicate javascript and php?
Groups: php.general 
Request: Send a blank email to php-general+get-36300@lists.php.net to get a copy of this message
I've used the <iframe> tag in Internet Exploder to talk to the server via javascript. It may be possible using a regular frame also. Here's the low down on how I did it. 1.) Some onclick, onchange ... action calls a javascript function that looks like this function getData() { document.all.hidden_frame.src = "databaseactions.php?getmesomedata=something"; } 2.) The output of databaseactions.php would look like <html> <head> <script language="JavaScript"> var contacts = new Array("Jeff Boyer","555-555-5555); </script> </head> <body onload="parent.loadselectbox(contacts);"> Put something here for debugging </body> </html> The frame is hidden (width and height set to 0) so the client does not see the output. 3.) A function on the main page called loadselectbox gets the array of data returned from the server. You need to rawurlencode the data elements in the array or javascript will complain. Tuna Out, Dustin > Hello Alex, > > Sunday, January 21, 2001, 4:20:53 AM, you wrote: > > AB> no without submitting information to the server with get or post. > > AB> for example, if a bit of javascript you have comes up > with some value, the > AB> only way you can get it to the server is to put it in a > get and send the > AB> user to that url: > > AB> http://www.mysite.com/index.php?your_js_var=your_value > > You could also post WDDX packets generated by JS, if you intend to > operate with large and complex data. Sometimes it's much more > convenient. But, of course, using POST, cause PHP haven't learned mind > reading yet :) > > -- > Best regards, > Max A. Derkachev mailto:kot@books.ru

« previous php.general (#36300) next »