Re: POSTing without a form?

Giganews Newsgroups
Subject: Re: POSTing without a form?
Posted by:  Stephen (ssans…@austin.rr.com)
Date: Fri, 04 Jul 2003

Daniel wrote:
> Ah, new question =) (Well, half-new, I asked something similar a while ago,
> but disregarded the question myself)
>
> Is there any way to post data to Javascript in a new page without using a
> form or,

It seems you mean something like:

oNewWin = window.open(...)
oNewWin.document.write(...)

Your phrase "post data to Javascript in a new page" is both confused and
confusing to me. Post is a type of request (a "request method") that
goes to a web server. The web server takes the request and does
something with it -- "post" usually means the request is turned over to
a specified process to run, with the result of that process (most of the
time) returned to the originating client or causing some change at the
server (or both). Sometimes what is returned may cause a new
browser-window to open and display content at the client, but you don't
really "submit to another window" or "post to Javascript".

For the data to go anywhere, you *must* use a form. Hmmm... someone will
point out exceptions (HTTPRequest); but basically in HTML, if you want
to the data to go anywhere, you must use a form. And the form elements
containing the data you want to send must be within the <form></form>.

You can create the new window and content without any submitting
anything at all--just by using the window.open() and document.write()
methods listed above.

  alternatively, to dynamically construct a "virtual" form object
> (such as new Form();) and submit it?

There are probably several ways of dynamically creating a form: using
createElement('form')and adding the necessary attributes, children, etc;
using "innerHTML"; or in certain circumstances using documet.write().
Also, don't forget the possibility of using the HTTPRequest approach
(there have been some fairly recent posts on this).

Watch out for wrapping of long url's...

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=bciuer%24j1rd4%241%40ID-142196.news.dfncis.de&rnum=1&prev=/groups%3Fq%3Dapplication/x-www-form-urlencoded%2Bgroup:comp.lang.javascript%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dcomp.lang.javascript%26scoring%3Dd%26selm%3Dbciuer%2524j1rd4%25241%2540ID-142196.news.dfncis.de%26rnum%3D1
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=3d455b6c.15542701%40news.cis.dfn.de&rnum=1&prev=/groups%3Fq%3Dhttprequest%2Bpost%2Bdata%2Bgroup:comp.lang.javascript%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dcomp.lang.javascript%26selm%3D3d455b6c.15542701%2540news.cis.dfn.de%26rnum%3D1

Regards,
Stephen

> Thanks in advance,
> Daniel

Replies

In response to

POSTing without a form? posted by Daniel on Fri, 4 Jul 2003