POSTing without a form?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel

    POSTing without a form?

    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, alternatively, to dynamically construct a "virtual" form object
    (such as new Form();) and submit it?

    Thanks in advance,
    Daniel



    --
    There are 10 kinds of people: Those who know binary and those who don't.


  • Stephen

    #2
    Re: POSTing without a form?

    Daniel wrote:[color=blue]
    > 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,[/color]

    It seems you mean something like:

    oNewWin = window.open(... )
    oNewWin.documen t.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[color=blue]
    > (such as new Form();) and submit it?
    >[/color]

    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...




    Regards,
    Stephen
    [color=blue]
    > Thanks in advance,
    > Daniel
    >
    >
    >[/color]

    Comment

    • Tim Williams

      #3
      Re: POSTing without a form?

      You can't POST between pages on the client-side, so you'll have to use GET.
      Just create a querystring and append to the next URL.
      Parse the "location" in the next page to retreive the info.
      or use frames
      or use cookies

      tim


      "Daniel" <sorry-no-email@i-get-virus-and-spam.com> wrote in message
      news:3f058526$0 $97165$edfadb0f @dread12.news.t ele.dk...[color=blue]
      > Ah, new question =) (Well, half-new, I asked something similar a while[/color]
      ago,[color=blue]
      > but disregarded the question myself)
      >
      > Is there any way to post data to Javascript in a new page without using a
      > form or, alternatively, to dynamically construct a "virtual" form object
      > (such as new Form();) and submit it?
      >
      > Thanks in advance,
      > Daniel
      >
      >
      >
      > --
      > There are 10 kinds of people: Those who know binary and those who don't.
      >
      >[/color]


      Comment

      • Daniel

        #4
        Re: POSTing without a form?


        "Stephen" <ssansom@austin .rr.com> wrote in message
        news:P2hNa.4095 7$XV.2609312@tw ister.austin.rr .com...[color=blue]
        > 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".[/color]

        Sorry, I should've just said "post" - the data will be used by a Javascript
        script in a new page, but that doesn't really matter... But I do mean post,
        because posted/form-submitted data is sent through HTTP headers, eliminating
        the possibility of hitting URL length barriers, and I have quite a lot of
        data to send ;)
        [color=blue]
        > 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).[/color]

        I'm gonna check out both createElement and the HTTPRequest thing and see
        what I can find.

        Thanks for the help, Stephen =)

        Daniel



        --
        There are 10 kinds of people: Those who know binary and those who don't.


        Comment

        • Daniel

          #5
          Re: POSTing without a form?


          "Daniel" <sorry-no-email@i-get-virus-and-spam.com> wrote in message
          news:3f091a7d$0 $97214$edfadb0f @dread12.news.t ele.dk...[color=blue]
          > Sorry, I should've just said "post" - the data will be used by a[/color]
          Javascript[color=blue]
          > script in a new page, but that doesn't really matter...[/color]

          Sloppy fingering here, it should've read "PHP constructed Javascript script"
          :)


          Comment

          • Daniel

            #6
            Re: POSTing without a form?


            "Tim Williams" <saxifraxREMOVE @THISpacbell.ne t> wrote in message
            news:AGnNa.747$ Hd2.243@newssvr 19.news.prodigy .com...[color=blue]
            > You can't POST between pages on the client-side, so you'll have to use[/color]
            GET.[color=blue]
            > Just create a querystring and append to the next URL.
            > Parse the "location" in the next page to retreive the info.
            > or use frames
            > or use cookies
            >
            > tim[/color]

            My mistake, I should've written that the data will be collected by a PHP
            script that creates Javascript. Sorry =)


            Comment

            • Markus Ernst

              #7
              Re: POSTing without a form?

              [color=blue]
              >
              > My mistake, I should've written that the data will be collected by a PHP
              > script that creates Javascript. Sorry =)
              >
              >[/color]

              You can create a GET querystring like this:
              <a href="file.php< ? if($data) echo '?data='.$data; ?">

              or POST via a form with hidden fields:
              <form method="post" action="file.ph p">
              <input type="hidden" name="data" value="<? echo $data; ?>">
              </form>

              I don't think that there are other possibilities.

              HTH

              --
              Markus


              Comment

              • Daniel

                #8
                Re: POSTing without a form?


                "Stephen" <ssansom@austin .rr.com> wrote in message
                news:P2hNa.4095 7$XV.2609312@tw ister.austin.rr .com...[color=blue]
                > 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>.[/color]

                Been looking into XML HTTPRequest, it fits my requirements exactly, and the
                IE/Mozilla requirements impose no problems, so YAY!! =)

                Thanks!


                Daniel




                --
                There are 10 kinds of people: Those who know binary and those who don't.


                Comment

                • Thoaren
                  New Member
                  • Apr 2006
                  • 4

                  #9
                  Hi,

                  So how did you did it? Can you give me an example?

                  Thanx,

                  Thoaren

                  Comment

                  Working...