JS get ASP page return value (load value) Implementation code _ Application Tips

Source: Internet
Author: User
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; CHARSET=GBK "/>
<title>getting Server side Data using ajax</title>
<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= "click Load" onclick= "Call_server ();"/>
<input type= "text" style= "WIDTH:265PX; height:68px "id=" aja_cnts "/>
</body>

Get page response.asp code: document.getElementById (' aja_cnts '). Value
Response.asp code Example:
Copy Code code as follows:

<%
Response.Write "Hello!" Welcome to Yau 9 Store! "
Response.Write "Our website is: http://you9luck.taobao.com"
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.