zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Js获取asp页面返回的值(加载值)实现代码

JSASP代码 实现 获取 页面 加载 返回
2023-06-13 09:14:42 时间
复制代码代码如下:

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gbk"/>
<title>GettingServersidedatausingAJAX</title>
</head>
<script>
functioncreat_Object(){
varxmlhttp;
if(!xmlhttp&&typeofXMLHttpRequest!="undefined"){
try{
xmlhttp=newXMLHttpRequest();
}
catch(e){
alert("YourbrowserisnotsupportingXMLHTTPRequest");<BR>xmlhttp=false;
}
}
else{
xmlhttp=newActiveXObject("Microsoft.XMLHTTP");
}
returnxmlhttp;
}
varrequest=creat_Object();
functionsever_interaction(){
if(request.readyState==1){
document.getElementById("aja_cnts").value="";
document.getElementById("aja_cnts").value="Loading...";
}
if(request.readyState==4){
varanswer=request.responseText;
document.getElementById("aja_cnts").value="";
document.getElementById("aja_cnts").value=answer;
}
}
functioncall_server(){
request.open("GET","Response.asp");
request.onreadystatechange=sever_interaction;request.send("");
}
</script>
<body>
<inputtype="button"name="btnLoad"id="btnLoad"value="点击加载"onclick="call_server();"/>
<inputtype="text"style="width:265px;height:68px;"id="aja_cnts"/>
</body>
</html>

获取页面Response.asp代码:document.getElementById("aja_cnts").value
Response.asp代码示例:
复制代码代码如下:

<%
Response.Write"您好!欢迎光临悠9小店!"
Response.Write"我们的网址是:http://you9luck.taobao.com"
%>