日期:2014-05-16  浏览次数:20809 次

Http.open "GET",url,false ;用GET方式可以直接把参数写在url中,如果采用POST方式,怎么提交表单数据?
set http=Server.createobject("Microsoft.XMLHTTP") 
Http.open "GET",url,false 
用GET方式可以直接把参数写在url中,
如果采用POST方式,怎么提交表单数据?

------解决方案--------------------
先在js里获取定义:
var ids="yourids";
var id = 5;

xmlhttp.open("POST","./XXX.action",true);
xmlhttp.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded");
xmlhttp.send("ids="+ids+"&id="+id);
------解决方案--------------------
Microsoft.XMLHTTP基本用法例子,在asp程式定义,调用,在另外一个页面实现功能! 
定义,调用(一般写成一个触发事件onblur) 
function progPM_onblur(){ 
if (frmAddPJ.prog_PM.value != ''){ 
var URL = 'chkPM.asp?progPM=' + frmAddPJ.prog_PM.value; 
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
xmlHttp.open("POST",URL,false); 
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset:big5") 
xmlHttp.send(); 
//var returnValue = eval(xmlHttp.responseBody);  //用responseBody只能取到單個,數字或者字母 
//var returnValue = eval(xmlHttp.responseText); //用responseBody只能取到一個或多個數字 
//var returnValue = xmlHttp.responseXML.xml;     //取出xml代碼 
//alert(returnValue);  不是很清楚的類型,最后测试,不要用eval,否则出错 
//alert(returnValue.toString().length()); 
var returnValue = xmlHttp.responseText; 
if (returnValue != 'Y') { 
 alert('該用戶不存在或沒有權限'); 
 frmAddPJ.prog_PM.value = ''; 
 frmAddPJ.prog_PM.focus(); 
 } 
 xmlHttp = null; 
 return; 
 } 



实现功能的页面, 
<!-- #include file = "header.asp" --> 
<% 
olecodepage = session.CodePage 
session.CodePage = 65001 
on error resume next 
progPM  = request.QueryString("progPM") 
if chkR(progPM,"M") = 0 then  '是否具有專案經理的權限 /调用了一个函数,其实就如一般的页面一样动作即可 
response.Write "N" 
else 
response.Write "Y" 
end if 
session.CodePage =  olecodepage 
%>