Re: Which Is The Better Approach To Working With Javascript?
- From: Jeff <jeff@xxxxxxxxxxxxxxx>
- Date: Wed, 09 Jul 2008 11:00:20 -0400
Patient Guy wrote:
"Twayne" <nobody@xxxxxxxxxxxxxxxxxxx> wrote in comp.lang.php:
.oO(sheldonlg)I mean no offense here, but I think the original answers based on the level of the OP were probably good ones; run it client side because the server likely doesn't provide it?. Perhaps the missed point was simply that servers would have to be checked to see if they would serve js, same as checking to see if and what version of PHP they provide, if they provide it, which almost all do AFAIK. So js is normally intended to be run on the client side, not the server side.
Patient Guy wrote:Wrong. JavaScript is just a language and can run everywhere if anSo, based on your response, you are telling me that a PHP processing
implementation has no interprocess communication capability, or
ability to interface with a (Java)script interpreter.
Hint: javascript does NOT run on the server.A server, or a server-associated process, can start a script host,
passing some form of input to it, and the script host does the
script interpretation, while the calling process waits for output.
However this is achieved, PHP (by design?) has no script interface,
based on your response.
Here, try this on for size.
Javascript is run **ONLY** on the client.
interpreter is available. Even PHP can be run in a client's browser if
you have the required plugin (at least for IE such a plugin exists!)
In any script that puts up aCorrect, but now you're talking about a particular implementation of a
page, if there is Javascript, that script is run on the client
**BEFORE** anything is sent to the server.
JS engine and the most common use of JS. But there are also various JS
engines available that run on a server.
http://en.wikipedia.org/wiki/Server-side_JavaScript
If a php script is invoked, either via a page post or from the hrefIf there's a JS engine available, then of course PHP can invoke a
of an anchor or from an httpRequest, it is invoked on the
**SERVER**. It gathers input from the calling form in one of two
ways. It can get that from $_GET or from $_POST or both, depending
upon the method of the calling form.
PHP can then send HTML back to the client for display. PHP does
**NOT** run Javascript.
Java- Script like it can call a Perl script, Python, Java ...
whatever. A programming language is never restricted to just a single
environment.
Micha
Or am I all wet? I'm not sure I see any value to running js for the client on the server side. Seems like js could put quite a load on a server if many people used it that way, since it's so prevalent in coding these days.
I got curious so I checked my own servers and they do not provide any js capability that I could find. I didn't ask support though; I'm trying to avoid js, but it can be pretty handy for some things, I know.
There are several reasons for running it on the server side, which were all given in the post with message ID
<news:Xns9AD554BCD7E9FUVAA@xxxxxxxxxxxx>
cited in the original post.
The reason all starts with the need to convert a pseudo-math plaintext notation into MathML. The parser and generator was originally written in Javascript, and that was ported to PHP so that string input from a form textarea control could apparently seamlessly be translated to MathML all within PHP.
But I want to tweak the code of the parser and generator, and I am quite familiar with Javascript, and much less so with PHP. It would be no issue at all if I can work easily with PHP at this very moment, for I would edit the PHP code rather than the Javascript code.
From the Wikipedia reference it appears that only JAXER has any DOM capabilities, and whether it can deal with MathML you would need to investigate. I'm thinking not. Most, if not all server side JS implementations are not concerned with doing client side type stuff, it's a very different animal than client side JS. Remember that the JS you are used to using only runs through a browser, that there is no standalone client side JS.
Now, it seems to me that rather that go through all this to possibly get nowhere that learning a little more PHP would be easier. It looks a lot like javascript to me to the point that when I embed javascript in my php it's hard for me to tell which is which!
Jeff
.
So given that I would rather make use of the original Javascript code---
and can---then the two ways of making use of the Javascript code was either to have PHP set up the delivered document to client with the input string bundled with the Javascript code and have it all done on the client side, or to run something like wscript or cscript from the server, which is the host interpreter for J(ava)script, and then run the output to PHP for deliver (thus, all done on the server side).
Surely both approaches are possible, but which of the two is more sensible?
- Follow-Ups:
- Re: Which Is The Better Approach To Working With Javascript?
- From: Geoff Berrow
- Re: Which Is The Better Approach To Working With Javascript?
- References:
- Which Is The Better Approach To Working With Javascript?
- From: Patient Guy
- Re: Which Is The Better Approach To Working With Javascript?
- From: Jerry Stuckle
- Re: Which Is The Better Approach To Working With Javascript?
- From: Patient Guy
- Re: Which Is The Better Approach To Working With Javascript?
- From: sheldonlg
- Re: Which Is The Better Approach To Working With Javascript?
- From: Michael Fesser
- Re: Which Is The Better Approach To Working With Javascript?
- From: Twayne
- Re: Which Is The Better Approach To Working With Javascript?
- From: Patient Guy
- Which Is The Better Approach To Working With Javascript?
- Prev by Date: Re: Which Is The Better Approach To Working With Javascript?
- Next by Date: Re: Which Is The Better Approach To Working With Javascript?
- Previous by thread: Re: Which Is The Better Approach To Working With Javascript?
- Next by thread: Re: Which Is The Better Approach To Working With Javascript?
- Index(es):
Relevant Pages
|