Re: XMLHttpRequest: POST with Data

Discussion in 'ASP General' started by Mike Winter, Aug 26, 2012.

  1. Mike Winter

    Mike Winter Guest

    On 23/08/2012 23:00, Gene Wirchenko wrote:
    > Dear JavaScripters:
    >
    > I am trying to pass data back and forth using XMLHttpRequest. I
    > have run into a few issues. The first one is the most important.
    >
    > 1) I can not get POST to work according to various documentation I
    > have found on the Web.
    >
    > Suppposedly, the .open() and .send() would be
    > oRequest.open("POST",Url,true);
    > oRequest.send(DataToSend);
    > but with this, at the server end, the .QueryString value is ""
    > regardless of what was supposedly sent.
    >
    > I have found that using the GET style of
    > oRequest.open("POST",Url+"?"+DataToSend,true);
    > oRequest.send();
    > does work. At least, it appears to.
    >
    > Am I doing something wrong, or is the documentation wrong?


    As has been indicated, you're looking in the wrong place for the data.
    The query string (.QueryString) is part of the URL used to locate the
    receiving page, hence when you modify the URL in the second example, the
    information is available.

    The POST method adds data as a "payload" in the request body sent to the
    server, and this is accessed differently through the Request.Form
    collection[1].

    If you're new to authoring server-side and you haven't already, I'd
    suggest that you read RFC 2616, Hypertext Transfer Protocol
    (HTTP/1.1)[2] to be sure you behave properly (especially when sending
    data from the server). You might also want to review Microsoft's
    overview of processing user input in ASP[3]. Though it refers to forms
    throughout, that's irrelevant in this case: the transmission method (GET
    vs. POST) is key.

    [snipped encoding question]

    Hope that helps,
    Mike


    Copied and follow-ups set to microsoft.public.inetserver.asp.general
    (NB. I don't read this board as I don't use ASP)

    [1] <http://msdn.microsoft.com/en-us/library/ms525985(v=vs.90)>
    [2] <http://www.w3.org/Protocols/rfc2616/rfc2616.html>
    [3] <http://msdn.microsoft.com/en-us/library/ms525182(v=vs.90)>

    --
    Mike Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Mike Winter, Aug 26, 2012
    #1
    1. Advertisements

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Vishal
    Replies:
    1
    Views:
    936
    Steve C. Orr [MVP, MCSD]
    Dec 21, 2004
  2. =?Utf-8?B?Z29yaWxsYQ==?=
    Replies:
    1
    Views:
    1,127
    Masudur
    May 25, 2007
  3. Hal Vaughan
    Replies:
    4
    Views:
    985
    Hal Vaughan
    Jan 14, 2008
  4. JT

    post data, then post again..

    JT, Sep 5, 2003, in forum: ASP General
    Replies:
    1
    Views:
    282
    Bite My Bubbles
    Sep 6, 2003
  5. Henri-Bastien

    POST a form with XmlHttpRequest

    Henri-Bastien, Mar 23, 2005, in forum: Javascript
    Replies:
    2
    Views:
    241
    Metaphis
    Mar 23, 2005
  6. Jarson
    Replies:
    5
    Views:
    763
    Lasse Reichstein Nielsen
    May 10, 2005
  7. libsfan01
    Replies:
    5
    Views:
    593
    Jeff North
    Dec 20, 2006
  8. gp
    Replies:
    1
    Views:
    264
Loading...