simulate a POST ACTION with javascript

Discussion in 'Javascript' started by q2005, Oct 28, 2004.

  1. q2005

    q2005 Guest

    Hi, all

    Is that possible I can do
    window.open("http://xserver1/app/typ/test/tesServer.php?aaa=111&bbb=222&ccc=
    333","","") to simulate a POST ACTION with a form rather than a GET ACTION?

    Jack
     
    q2005, Oct 28, 2004
    #1
    1. Advertising

  2. q2005

    Evertjan. Guest

    q2005 wrote on 28 okt 2004 in comp.lang.javascript:

    > Is that possible I can do
    > window.open("http://xserver1/app/typ/test/tesServer.php?aaa=111&bbb=222
    > &ccc= 333","","") to simulate a POST ACTION with a form rather than a
    > GET ACTION?
    >


    <form id=f method=post target="_blank"
    action="http://xserver1/app/typ/test/tesServer.php">
    <input type=hidden name=aaa value="111"
    <input type=hidden name=bbb value="222"
    <input type=hidden name=ccc value="333"
    </form>

    <script ...>
    document.getElementById("f").submit()
    ....

    not tested

    ==========

    Or you do the same targetting
    a previously window.open()ed and named window.

    ==========

    Or you can define the whole form in DOM

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)
     
    Evertjan., Oct 28, 2004
    #2
    1. Advertising

  3. q2005

    Fox Guest

    q2005 wrote:
    > Hi, all
    >
    > Is that possible I can do
    > window.open("http://xserver1/app/typ/test/tesServer.php?aaa=111&bbb=222&ccc=
    > 333","","") to simulate a POST ACTION with a form rather than a GET ACTION?
    >
    > Jack
    >
    >


    function
    handleSubmit(formRef)
    {
    window.open("","formTargetWindow");

    formRef.target = "formTargetWindow";
    formRef.method = "post";
    formRef.action = "http://xserver1/app/typ/test/tesServer.php";

    formRef.submit();

    return false;
    }

    There's no reason why you need javascript for this (unless you need to
    customize the window):

    <form action = "formURL.xxx" method=post target=formTargetWindow>

    (just give the window any name you want and post the form to it -- it's
    probably a "safer" popup because I don't believe these are suppressed by
    popup blockers [could be wrong tho])


    js demo in action:
    http://site-creations.com/demo/postform2win.htm

    all the action script does is var_dump($_POST) wrapped in xmp tags.

    Fox
    ************
     
    Fox, Oct 28, 2004
    #3
  4. On Thu, 28 Oct 2004 17:29:05 +1000, q2005 <> wrote:

    > Is that possible I can [use a query string] to simulate a POST ACTION
    > with a form rather than a GET ACTION?


    Generally, no. If a server-side document expects POST data, it will
    generally use methods that obtain *only* POST data.

    The only[1] way to submit POST data is via a form.

    Mike


    [1] Certain hosts may provide other ways, but you can't rely on them on
    the Web.

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, Oct 28, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Al Cadalzo

    How to simulate a form post?

    Al Cadalzo, Feb 17, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    7,600
    Al Cadalzo
    Feb 17, 2004
  2. delph
    Replies:
    3
    Views:
    1,370
    Andrea Desole
    May 13, 2005
  3. dast

    Simulate post at webpage

    dast, Sep 15, 2005, in forum: C++
    Replies:
    2
    Views:
    333
    =?ISO-8859-1?Q?Stefan_N=E4we?=
    Sep 15, 2005
  4. BarryX

    Simulate Form Post on Server Side

    BarryX, Sep 26, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    536
    Patrice
    Sep 26, 2007
  5. nospam
    Replies:
    1
    Views:
    457
    sloan
    Oct 13, 2007
Loading...

Share This Page