当前位置: 移动技术网 > IT编程>开发语言>Asp > Js获取asp页面返回的值(加载值)实现代码

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

2017年12月08日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<title>getting server side data using ajax</title>
</head>
<script>
function creat_object() {
var xmlhttp;
if (!xmlhttp && typeof xmlhttprequest != 'undefined') {
try {
xmlhttp = new xmlhttprequest();
}
catch (e) {
alert("your browser is not supporting xmlhttprequest"); <br> xmlhttp = false;
}
}
else {
xmlhttp = new activexobject("microsoft.xmlhttp");
}
return xmlhttp;
}
var request = creat_object();
function sever_interaction() {
if (request.readystate == 1) {
document.getelementbyid('aja_cnts').value = '';
document.getelementbyid('aja_cnts').value = 'loading...';
}
if (request.readystate == 4) {
var answer = request.responsetext;
document.getelementbyid('aja_cnts').value = '';
document.getelementbyid('aja_cnts').value = answer;
}
}
function call_server() {
request.open("get", "response.asp");
request.onreadystatechange = sever_interaction; request.send('');
}
</script>
<body>
<input type="button" name="btnload" id="btnload" value="点击加载" onclick="call_server();" />
<input type="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"
%>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网