http_request with both GET and POST possible?

N

nick

Is it possible to do the following? (note this is more of a curiosity
thing than problem solving :))

var parameters = 'b=3&d=4';
http_request = new ActiveXObject("Msxml2.XMLHTTP");
http_request.open('POST', 'index.php?a=1', true);
http_request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
 
T

Thomas 'PointedEars' Lahn

nick said:
Is it possible to do the following? (note this is more of a curiosity
thing than problem solving :))

var parameters = 'b=3&d=4';
http_request = new ActiveXObject("Msxml2.XMLHTTP");

All identifiers should be declared.
http_request.open('POST', 'index.php?a=1', true);
http_request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);

Of course the core part of it is possible (the above runs in IE only).
You would have had satisfied your curiosity already if you had tried first.

However, "both GET and POST" is wrong; one HTTP request can only be of one
type, the POST type here. Whether the query-part of the request URI is
evaluated or not for such requests, depends entirely on the server-side
software.

This question has not anything to do with scripting at all, it is an HTTP
issue.


PointedEars
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top