POST method in AJAX

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    POST method in AJAX

    Plz explain ....
    why three lines added when the request made POST method using AJAX?

    [code=javascript]
    http_request.se tRequestHeader( "Content-type", "applicatio n/x-www-form-urlencoded");
    http_request.se tRequestHeader( "Content-length", parameters.leng th);
    http_request.se tRequestHeader( "Connection ", "close");
    [/code]

    Kind regards,
    Dmjpro.
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    [CODE=javascript]
    http_request.se tRequestHeader( "Content-type", "applicatio n/x-www-form-urlencoded"); // tells the server what the content type being sent is.
    http_request.se tRequestHeader( "Content-length", parameters.leng th); // tells the server how long the content is.
    http_request.se tRequestHeader( "Connection ", "close"); // tells the server to close the connection when its done.
    [/CODE]

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by iam_clint
      [CODE=javascript]
      http_request.se tRequestHeader( "Content-type", "applicatio n/x-www-form-urlencoded"); // tells the server what the content type being sent is.
      http_request.se tRequestHeader( "Content-length", parameters.leng th); // tells the server how long the content is.
      http_request.se tRequestHeader( "Connection ", "close"); // tells the server to close the connection when its done.
      [/CODE]
      Would u be more in detaills??
      I mean why????

      Kind regards,
      Dmjpro.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        The difference between GET and POST is obvious. Using the GET method, you don't send anything through the send method whereas with POST you send data. For that, you set the headers.

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          Originally posted by acoder
          The difference between GET and POST is obvious. Using the GET method, you don't send anything through the send method whereas with POST you send data. For that, you set the headers.
          Why do we do it explicitly?

          Why not JS engine do for us, as i mention the POST method in open function?
          And one more thing.
          what application/x-www-form-urlencoded does it mean?
          Please explain.

          Kind regards,
          Dmjpro.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            See this link which describes the POST headers.

            Comment

            Working...