Robert Oschler wrote:
I know there isn't any $_POST array in Javascript, it exists on the server
side accessible from PHP and other server side scripting languages. But I
knew it would let you know specifically what data I'm after.
If data is posted to the server and JavaScript is used on the server
(for instance in a framework like ASP) then on the server of course the
posted data is exposed to JavaScript e.g. with
Request.Form
in ASP.
Is there any way to get the data that is POSTED to a web page from
client-side Javascript? Or does only the server get access to it?
A HTTP client can make a HTTP POST request sending some data to a HTTP
server and then that data can be processed on the server, if you have
PHP on the server then you can do it with PHP, but if you have
JavaScript on the server then you can do it with JavaScript for
instance. Data does not get POSTed to a web page as such, indeed if you
make a HTTP POST request to a static resource on a HTTP server then you
usually get an error.
As for client-side JavaScript accessing POST data when a from is
submitted (e.g. when for instance the POST request is initiated) then
client-side script in the onsubmit handler can of course use the
client-side DOM to read out any form data but you are reading out the
form controls in the DOM and not a data structure the browser exposes of
data it is going to post. And when your onsubmit handler is done (and
returns true) then the browser makes the HTTP request and at that stage
script in the HTML document certainly has no access to the POSTed data.
And script in the next HTML document the server sends as the response to
the posted data again has no access to the posted data unless (as
already pointed out) of course the server-side script tries to pass on
the data to script.
--
Martin Honnen
http://JavaScript.FAQTs.com/