By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,253 Members | 1,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,253 IT Pros & Developers. It's quick & easy.

POST method in AJAX

dmjpro
100+
P: 2,476
Plz explain ....
why three lines added when the request made POST method using AJAX?

Expand|Select|Wrap|Line Numbers
  1.  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  2.       http_request.setRequestHeader("Content-length", parameters.length);
  3.       http_request.setRequestHeader("Connection", "close");
  4.  
Kind regards,
Dmjpro.
Jun 21 '07 #1
Share this Question
Share on Google+
5 Replies


iam_clint
Expert 100+
P: 1,208
Expand|Select|Wrap|Line Numbers
  1. http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // tells the server what the content type being sent is.
  2. http_request.setRequestHeader("Content-length", parameters.length); // tells the server how long the content is.
  3. http_request.setRequestHeader("Connection", "close"); // tells the server to close the connection when its done.
  4.  
Jun 21 '07 #2

dmjpro
100+
P: 2,476
Expand|Select|Wrap|Line Numbers
  1. http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // tells the server what the content type being sent is.
  2. http_request.setRequestHeader("Content-length", parameters.length); // tells the server how long the content is.
  3. http_request.setRequestHeader("Connection", "close"); // tells the server to close the connection when its done.
  4.  
Would u be more in detaills??
I mean why????

Kind regards,
Dmjpro.
Jun 21 '07 #3

acoder
Expert Mod 15k+
P: 16,027
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.
Jun 22 '07 #4

dmjpro
100+
P: 2,476
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.
Jun 22 '07 #5

acoder
Expert Mod 15k+
P: 16,027
See this link which describes the POST headers.
Jun 22 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.