用XMLHTTP对象Post表单

80酷酷网    80kuku.com

  xml|对象

    试验如下:
提交Form代码(Test.htm):


<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<script language=javascript>
function Test()
{
strA = "submit1=Submit&text1=scsdfsd"; file://Looks like QueryString,But there's no "?" here!
var oReq = new ActiveXObject("MSXML2.XMLHTTP");
oReq.open("POST","http://ServerName/VDir/TstResult.asp",false);
oReq.setRequestHeader("Content-Length",strA.length);
oReq.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
oReq.send(strA);
txt1.document.write(oReq.responseText);
}
</script>
</HEAD>
<BODY>
<INPUT type=button value="go!" >

<IFRAME name=txt1></IFRAME>
</BODY>
</HTML>


  这是接受Form数据的ASP,很简单。
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<TABLE border="1" cellpadding=0 cellspacing=0>
<%For Each Key In Request.Form%>
<TR>
<TD><%=Key%></TD>
<TD><%=Request.Form(Key)%></TD>
</TR>
<%Next%>
</TABLE>
</BODY>
</HTML>


Enjoy it! :)



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: