↓クライアント側Javascript
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
var postdata = "TEST=123";
xmlHttp.open("POST", "../server_cs.aspx",true);
xmlHttp.send(postdata);
↓サーバ側server_cs.aspx(C#)
<script runat="server">
void Page_Load(Object sender, EventArgs e) {
string a = Request.QueryString["TEST"];
}
</script>
string a に値が入りません。(Request.QueryString["TEST"]はnullになっている)
どこに問題がありますでしょうか?(POSTが前提、他のアドインは考慮しない)
↓クライアント側Javascript
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
/* &を付ける */
var postdata = "&TEST=123";
xmlHttp.open("POST", "../server_cs.aspx",true);
/* ヘッダーを設定 */
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlHttp.send(postdata);
↓サーバ側server_cs.aspx(C#)
<script runat="server">
できました~!
サーバ側はRequest.Formですね。ありがとうございました。
回答者 | 回答 | 受取 | ベストアンサー | 回答時間 | |
---|---|---|---|---|---|
1 | ![]() |
23回 | 21回 | 4回 | 2006-11-09 18:15:56 |
Formもからっぽです。
<form method="POST" ... >
でsubmitするなら、Request.Formで受け取れそうなんですが、xmlHttpで上記ロジックでやるとだめみたいです。。。