Re: Calling Javascript-function from php-script ...
| From: | Andrew Lopucki | Date: | Wed, 20 Mar 2002 17:50:37 +0000 |
| Subject: | Re: Calling Javascript-function from php-script ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-89364@lists.php.net to get a copy of this message | ||
I think the point here is that it be made clear to those who might get
confused that the javascript (unless it's a server-side script) is running in
a browser and as such there is no way for the server to 'make a call to it by
URL.' The Javascript can call the server but the server-side PHP script
cannot call the client. Therefore, no PHP script can 'call' a javascript
function.
On Wednesday 20 March 2002 12:44 pm, Kevin Stone wrote:
> I'm not quite sure what you mean... If Javascript were disabled then
> this whole argument would be moot. Since our method requires Javascript
> to properly function we're really not interested in that particular
> situation. :)
>
> There are two ways a PHP script (or any scripting language for that
> matter) can send input to a Javascript. One, by dynamically generating
> a local Javascript with the lines of code necessary to perform a certain
> task. Two, by sending information through the URL string to a remote
> Javascript which runs functions based on that information.
>
> Classic Input/Output. It doesn't matter where the input is coming from
> so long as the program gets what is expecting. So in this sense the two
> unrelated programs (one server side, one client side) are communicating,
> just not directly.
>
> Bottom line is the method works so I don't understand what there is to
> debate. See here for a working example....
>
> http://www.helpelf.com/fetch_data.html
>
> It's not very sophisticated yet (all the junk left in the URL, et al).
> But it does what I'm talking about. You can copy & paste this
> Javascript into any web page and it'll return the same database
> information gathered by the PHP script.
> -Kevin
>
> -----Original Message-----
> From: Alexander Skwar [mailto:ASkwar@host.homelinux.org]
> Sent: Tuesday, March 19, 2002 4:27 PM
> To: Kevin Stone
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Calling Javascript-function from php-script ...
>
> »Kevin Stone« sagte am 2002-03-19 um 14:11:42 -0700 :
> > Not entirely true. Javascript is directly linked to HTML and HTML is
> > directly linked to PHP so you can have PHP talk to Javascript through
> > HTML.
>
> I still don't agree. You can of course create JavaScripts dynamically
> in PHP. However, PHP won't talk to JS, it's the browser which will
> execute the dynamically created JS and then maybe talk back to the
> server and thus execute some PHP code. This may seem like nitpicking,
> but I don't think it is. If PHP were to execute the JS, it would work
> even when the user had disabled JS in his browser.
>
> Alexander Skwar