This article introduces in detail the implementation method of JS getting the value returned by the asp page (loading value). Friends who need to know more can refer to the copy code. The code is as follows:
<!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 create_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 = create_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=Click to load onclick=call_server(); />
<input type=text style= width:265px; height:68px; id=aja_cnts />
</body>
</html>
Get the page Response.asp code: document.getElementById('aja_cnts').value
Response.asp code example:
Copy the code code as follows:
<%
Response.Write Hello! Welcome to You9 Store!
Response.Write Our website is: http://www.vevb.com
%>