How to similate HTTP POST request by JavaScript?

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

    How to similate HTTP POST request by JavaScript?

    How can I simulate HTTP post request by JavaScript?

    When I select from <SELECT> combo box. onClick will call JavaScript
    function.
    I want this function to send HTTP POST request with the selected index of
    the combo box.
    To do this, somehow the function must simulate HTTP POST request.

    Thanks in advance.
  • Evertjan.

    #2
    Re: How to similate HTTP POST request by JavaScript?

    Richard Hockey wrote on 07 jul 2003 in comp.lang.javas cript:
    [color=blue]
    > I'm not sure you can 'simulate' a HTTP post request, but you can
    > submit a form using javascript to set the method, and to execute from
    > submission (you can also set the action and target window):
    >
    > document.forms['myform'].method='post';
    > document.forms['myform'].action='proces s.php';
    > document.froms['myform'].target='_self' ;
    > document.forms['myform'].submit();
    >[/color]

    You are right.

    It is not simulating a post http-request,

    but simulating a classical HTTP-only post request.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Martin Honnen

      #3
      Re: How to similate HTTP POST request by JavaScript?



      reneeccwest wrote:[color=blue]
      > How can I simulate HTTP post request by JavaScript?
      >
      > When I select from <SELECT> combo box. onClick will call JavaScript
      > function.
      > I want this function to send HTTP POST request with the selected index of
      > the combo box.
      > To do this, somehow the function must simulate HTTP POST request.[/color]

      Why don't you use HTML?
      <form action="whateve r.php" method="POST">
      <select name="selectNam e">
      <option>...</option>
      <option>...</option>
      ...
      </select>
      <input type="submit">
      </form>

      The browser will send a HTTP POST request when the submit button is
      clicked/pressed without needing any script.

      --

      Martin Honnen


      Comment

      • Stuart Palmer

        #4
        Re: How to similate HTTP POST request by JavaScript?

        <form name="MyForm" action="nextpag e.asp" method="POST">
        <select name="selectNam e" onChange="docum ent.MyForm.subm it">
        <option>make a selection</option>
        <option value = "one">one</option>
        <option value = "two">two</option>
        ...
        </select>
        <input type="submit">
        </form>


        try something like this. Onclick is wrong because as soon as you click it
        would send, without you chnaging anything.

        Keep a submit button available for non JS users.

        Does that help? If not, let us see some code and tell us exactly what you
        want it to do.

        Stu


        "reneeccwes t" <reneeccwest@ho tmail.com> wrote in message
        news:9f9d6d21.0 307062128.279dd 614@posting.goo gle.com...[color=blue]
        > How can I simulate HTTP post request by JavaScript?
        >
        > When I select from <SELECT> combo box. onClick will call JavaScript
        > function.
        > I want this function to send HTTP POST request with the selected index of
        > the combo box.
        > To do this, somehow the function must simulate HTTP POST request.
        >
        > Thanks in advance.[/color]


        Comment

        Working...