⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajax_xmlhttprequest.asp@output=print

📁 W3Schools tutorial..web designing
💻 ASP@OUTPUT=PRINT
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>AJAX XMLHttpRequest Object</title>
 
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />

<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

</head>
<body>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

<h1>AJAX - The XMLHttpRequest Object</h1>
<a href="ajax_browsers.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="ajax_server.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>
<hr />

<h2>AJAX - More About the XMLHttpRequest Object</h2>
<p>Before sending data to the server, we have to explain three important 
properties of the XMLHttpRequest object.</p>
<h3>The onreadystatechange Property</h3>
<p>After a request to the server, we need a function that can receive the data 
that is returned by the server.</p>
<p>The onreadystatechange property stores the function that will process the 
response from a server. The following code defines an empty function and sets 
the onreadystatechange property at the same time:</p>

<table class="ex" width="100%" border="1" id="table6"><tr><td>
<pre>xmlHttp.onreadystatechange=function()
{
// We are going to write some code here
}</pre>
</td></tr></table>
<h3>The readyState Property</h3>
<p>The readyState property holds the status of the server's response. Each time the readyState changes, 
the onreadystatechange function will be executed.</p>
<p>Here are the possible values for the readyState property:</p>

<table class="ex" border="1" width="100%" cellpadding="2" cellspacing="0" id="table7">
<tr><th align="left" width="10%">State</th><th align="left">Description</th></tr>
<tr><td>0</td><td>The request is not initialized</td></tr>
<tr><td>1</td><td>The request has been set up</td></tr>
<tr><td>2</td><td>The request has been sent</td></tr>
<tr><td>3</td><td>The request is in process</td></tr>
<tr><td>4</td><td>The request is complete</td></tr>
</table>

<p>We are going to add an If statement to the onreadystatechange function to test if 
our response is complete (this means that we can get our data):</p>

<table class="ex" width="100%" border="1" id="table8"><tr><td>
<pre>xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  // Get the data from the server's response
  }
}</pre>
</td></tr></table>
<h3>The responseText Property</h3>
<p>The data sent back from the server can be retrieved with the responseText property.</p>
<p>In our code, we will set the value of our &quot;time&quot; input field  
equal to responseText:</p>

<table class="ex" width="100%" border="1" id="table9"><tr><td>
<pre>xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
  {
  document.myForm.time.value=xmlHttp.responseText;
  }
}</pre>
</td></tr></table>
<p>The next chapter shows how to ask the server for some data!</p>
<hr />

<a href="ajax_browsers.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="ajax_server.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -