一、ASP例子:
function GetSms()
Dim HttpUrl,https,xml
HttpUrl = "http://mb345.com:999/WS/Get.aspx?CorpID=" & userid & "&Pwd=" & password
Set https = Server.CreateObject("MSXML2.XMLHTTP")
https.open "post", HttpUrl, False
https.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
https.send '===这里还可以带参数
GetSms=bytes2BSTR(https.responseBody) '======除了https.responseBody还有https.responseXml,https.responseText
End function
二、js例子:
do_checkuser(document.frmLogin.dbid.value,document.frmLogin.txtLoginID.value,document.frmLogin.txtLogPass.value);
/*============================================Ajax=================================*/
function do_checkuser(DBID,LoginID,LogPass)
{
do_PostAjax("rtx_checkuser.asp?DBID="+DBID+"&txtLoginID="+LoginID+"&txtLogPass="+LogPass);
}
function do_PostAjax(url)//向url页面发出请求;
{
createXmlHttp();
xmlHttp.onreadystatechange=getAjax_Result;//回调函数
xmlHttp.open("post",url,true);
xmlHttp.setRequestHeader("Method", "post "+url+" HTTP/1.1");
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(null);
}
function getAjax_Result()//服务器响应本页面并从服务器带回xmlHttp.responseText;
{
if(xmlHttp.readystate==4)
{
if(xmlHttp.status==200)
{
var b=xmlHttp.responseText;
if(b=="true"){
document.frmLogin.AppId.value="<%=rtx_appid%>";
document.frmLogin.Account.value=document.frmLogin.txtLoginID.value;
document.frmLogin.Pwd.value=document.frmLogin.txtLogPass.value;
document.frmLogin.ReservedString0.value=document.frmLogin.DBID.value; //ReservedString0这些名称由RTX方定
document.frmLogin.submit();
}//====提交
else{alert("用户名或密码不对,不能保存");}
return;
/*
root = xmlHttp.responseXML.documentElement;
nodelist=root.childNodes;
for(i=0;i<nodelist.length;i++){
if(nodelist[i].nodeType==1){
var b=nodelist[i].attributes[0].value;
if(b=="true"){
document.frmLogin.AppId.value="<%=rtx_appid%>";
document.frmLogin.Account.value=document.frmLogin.txtLoginID.value;
document.frmLogin.Pwd.value=document.frmLogin.txtLogPass.value;
document.frmLogin.ReservedString0.value=document.frmLogin.DBID.value; //ReservedString0这些名称由RTX方定
document.frmLogin.submit();
}//====提交
else{alert("用户名或密码不对,不能保存");}
}
}*/
}
}
}
function createXmlHttp()
{
try
{
xmlHttp = new XMLHttpRequest();
}
catch (e1)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2)
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
}
}
/*=========================================Ajax end=================================*/