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

📄 ajax_server.asp

📁 W3Schools tutorial..web designing
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<!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 - Request a Server</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" />

<link rel="stylesheet" type="text/css" href="../stdtheme.css" />

<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>

<a name="top"></a>
<table cellpadding="0" cellspacing="0" width="100%" bgcolor="#808080">
<tr>
<td width="234" valign="top">
<a href="../default.htm"><img src="../images/w3default80.jpg" border="0" alt="W3Schools" /></a>
</td>
<th valign="middle" align="left" class="right">
<iframe style="background-color:#808080" src="../banners/bannerframe.asp@adpartner=aspall2" height="90" width="728"
marginwidth="0" marginheight="0" frameborder="0" scrolling="no">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>

<br /></th>
</tr>
</table>

<table style="margin-left:1px" width="800px" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="137" class="content" valign="top"><br />
<a class="left" href="../default.asp" target="_top">
<img src="../images/homeicon.gif" border="0" alt="home" /></a>
<a class="left" href="../default.asp" target="_top">
<b>HOME</b></a>
<br /><br />
<b>AJAX Basic</b><br />
<a class="left" target="_top" href="default.asp" >AJAX HOME</a><br />
<a class="left" target="_top" href="ajax_intro.asp" >AJAX Intro</a><br />
<a class="left" target="_top" href="ajax_httprequest.asp" >AJAX HTTP Request</a><br />
<a class="left" target="_top" href="ajax_example.asp" >AJAX Example</a><br />
<a class="left" target="_top" href="ajax_browsers.asp" >AJAX Browsers</a><br />
<a class="left" target="_top" href="ajax_xmlhttprequest.asp" >AJAX XMLHttpRequest</a><br />
<a class="left" target="_top" href="ajax_server.asp" style='font-weight:bold;'>AJAX Server</a><br />
<a class="left" target="_top" href="ajax_serverscript.asp" >AJAX Server Script</a><br />
<br />
<b>AJAX Advanced</b><br />
<a class="left" target="_top" href="ajax_example_suggest.asp" >AJAX Suggest</a><br />
<a class="left" target="_top" href="ajax_source.asp" >AJAX Source</a><br />
<a class="left" target="_top" href="ajax_database.asp" >AJAX Database</a><br />
<a class="left" target="_top" href="ajax_xmlfile.asp" >AJAX XML File</a><br />
<a class="left" target="_top" href="ajax_responsexml.asp" >AJAX ResponseXML</a><br />
<br />
<b>AJAX Examples</b><br />
<a class="left" target="_top" href="ajax_examples.asp" >AJAX Examples</a><br /><br />
<b>Selected Reading</b><br />
<a class="left" target="_top" href="../browsers/browsers_stats.asp">Web Statistics</a><br />
<a class="left" target="_top" href="../site/site_glossary.asp">Web Glossary</a><br />
<a class="left" target="_top" href="../hosting/default.asp">Web Hosting</a><br />
<a class="left" target="_top" href="../quality/default.asp">Web Quality</a><br /><br />
<a class="left" target="_top" href="../forum/default.asp">W3Schools Forum</a><br /><br />
<a class="left" target="_top" href="../about/about_helping.asp">Helping W3Schools</a><br /><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3440800076797949";
/*LeftLinkUnit*/
google_ad_slot = "4854527104";
google_ad_width = 120;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="../../pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
<td valign="top">
<table style="border: 1px solid gray" width="100%" bgcolor="#FFFFFF" border="0" cellpadding="5" cellspacing="0">
<tr>
<td>

<h1>AJAX - Request a Server</h1>
<a href="ajax_xmlhttprequest.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="ajax_serverscript.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>
<hr />

<h2>AJAX - Sending a Request to the Server</h2>
<p>To send off a request to the server, we use the open() method and the send() 
method.</p>
<p>The open() method takes three arguments. The first argument defines which 
method to use when sending the request (GET or POST). The second argument 
specifies the URL of the server-side script. The third argument specifies that 
the request should be handled asynchronously. The send() method sends the request off to the 
server. If we assume that the HTML and ASP file are in the same directory, the code 
would be: </p>

<table class="ex" width="100%" border="1" id="table10"><tr><td>
<pre>xmlHttp.open(&quot;GET&quot;,&quot;time.asp&quot;,true);
xmlHttp.send(null);</pre>
</td></tr></table>
<p>Now we must decide when the AJAX function should be executed. We will let the 
function run &quot;behind the scenes&quot; when the user types something in the username 
text field:</p>

<table class="ex" width="100%" border="1" id="table11"><tr><td>
<pre>&lt;form name=&quot;myForm&quot;&gt;
Name: &lt;input type=&quot;text&quot;
onkeyup=&quot;ajaxFunction();&quot; name=&quot;username&quot; /&gt;
Time: &lt;input type=&quot;text&quot; name=&quot;time&quot; /&gt;
&lt;/form&gt;</pre>
</td></tr></table>
<p>Our updated AJAX-ready &quot;testAjax.htm&quot; file now looks like this:</p>

<table class="ex" width="100%" border="1" id="table12"><tr><td>
<pre>&lt;html&gt;<br />&lt;body&gt;</pre>
<pre>&lt;script type=&quot;text/javascript&quot;&gt;<br />function ajaxFunction()
{<br />var xmlHttp;
try
  {<br />  // Firefox, Opera 8.0+, Safari<br />  xmlHttp=new XMLHttpRequest();<br />  }
catch (e)
  {<br />  // Internet Explorer<br />  try
    {<br />    xmlHttp=new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);<br />    }
  catch (e)
    {<br />    try
      {<br />      xmlHttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);<br />      }
    catch (e)
      {<br />      alert(&quot;Your browser does not support AJAX!&quot;);<br />      return false;<br />      }<br />    }<br />  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.myForm.time.value=xmlHttp.responseText;
      }
    }
  xmlHttp.open(&quot;GET&quot;,&quot;time.asp&quot;,true);
  xmlHttp.send(null);<br />  }<br />&lt;/script&gt;</pre>
<pre>&lt;form name=&quot;myForm&quot;&gt;
Name: &lt;input type=&quot;text&quot;
onkeyup=&quot;ajaxFunction();&quot; name=&quot;username&quot; /&gt;
Time: &lt;input type=&quot;text&quot; name=&quot;time&quot; /&gt;
&lt;/form&gt;</pre>
<pre>&lt;/body&gt;
&lt;/html&gt;</pre>
</td></tr></table>
<p>The next chapter makes our AJAX application complete with the &quot;time.asp&quot; 
script.</p>
<hr />

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

⌨️ 快捷键说明

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