例子,在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
%>
浙公网安备 33010602011771号