﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Sun River-随笔分类-Ajax</title><link>http://www.blogjava.net/SunRiver/category/15315.html</link><description>Topics about Java EE, XML,AJAX,SOA,OSGi,DB, .NET etc.</description><language>zh-cn</language><lastBuildDate>Wed, 13 Jun 2007 22:42:40 GMT</lastBuildDate><pubDate>Wed, 13 Jun 2007 22:42:40 GMT</pubDate><ttl>60</ttl><item><title>AJAX/Javascript XML Tips &amp; Tricks</title><link>http://www.blogjava.net/SunRiver/archive/2007/06/14/124207.html</link><dc:creator>Sun River</dc:creator><author>Sun River</author><pubDate>Wed, 13 Jun 2007 22:40:00 GMT</pubDate><guid>http://www.blogjava.net/SunRiver/archive/2007/06/14/124207.html</guid><description><![CDATA[Here are some XML processing examples in Javascript. If you've got some XML data with XMLHttpRequest (there is actually no XMLHttpRequest in the examples - we create the XML object from a string - can be handy too) you need to read/convert etc. it to some other format and do something with it. Traversing a DOM/XML tree can be tricky, so have a look at these examples: <br><strong>Example #1:<br></strong>Using getElementsByTagName, we iterate thru the XML tree and read the numerous children/sibling.
<pre>&lt;html&gt;
&lt;body&gt;
&lt;script&gt;
var xmlstring = '&lt;?xml version=\"1.0\"?&gt;\
&lt;shoppingcart date="14-10-2005" total="123.45"&gt;\
&lt;item code="12345"&gt;\
&lt;name&gt;Widget&lt;/name&gt;\
&lt;quantity&gt;1&lt;/quantity&gt;\
&lt;/item&gt;\
&lt;item code="54321"&gt;\
&lt;name&gt;Another Widget&lt;/name&gt;\
&lt;quantity&gt;2&lt;/quantity&gt;\
&lt;/item&gt;\
&lt;/shoppingcart&gt;';
// convert the string to an XML object
var xmlobject = (new DOMParser()).parseFromString(xmlstring, "text/xml");
// get the XML root item
var root = xmlobject.getElementsByTagName('shoppingcart')[0];
var date = root.getAttribute("date");
alert("shoppingcart date=" + date);
var items = root.getElementsByTagName("item");
for (var i = 0 ; i &lt; items.length ; i++) {
// get one item after another
var item = items[i];
// now we have the item object, time to get the contents
// get the name of the item
var name = item.getElementsByTagName("name")[0].firstChild.nodeValue;
// get the quantity
var quantity = item.getElementsByTagName("quantity")[0].firstChild.nodeValue;
alert("item #" + i + ": name=" + name + " quantity=" + quantity);
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<pre><strong>Example #2:<br></strong>Here is a more universal example with the method "childNodes".
<pre>&lt;html&gt;
&lt;body&gt;
&lt;script&gt;
var xmlstring = '&lt;?xml version="1.0"?&gt;\
&lt;root&gt;\
&lt;data&gt;\
&lt;row&gt;\
&lt;cell&gt;Admiral&lt;/cell&gt;\
&lt;cell&gt;Melon&lt;/cell&gt;\
&lt;cell&gt;Carrot&lt;/cell&gt;\
&lt;/row&gt;\
&lt;row&gt;\
&lt;cell&gt;Captain&lt;/cell&gt;\
&lt;cell&gt;Banana&lt;/cell&gt;\
&lt;cell&gt;Zucchini&lt;/cell&gt;\
&lt;/row&gt;\
&lt;/data&gt;\
&lt;data&gt;\
&lt;row&gt;\
&lt;cell&gt;Midshipman&lt;/cell&gt;\
&lt;cell&gt;Orange&lt;/cell&gt;\
&lt;cell&gt;Potatoe&lt;/cell&gt;\
&lt;/row&gt;\
&lt;/data&gt;\
&lt;/root&gt;';
// convert the string to an XML object
var xmlobject = (new DOMParser()).parseFromString(xmlstring, "text/xml");
// get the XML root item
var root = xmlobject.getElementsByTagName('root')[0];
for (var iNode = 0; iNode &lt; root.childNodes.length; iNode++) {
var node = root.childNodes.item(iNode);
for (i = 0; i &lt; node.childNodes.length; i++) {
var sibling = node.childNodes.item(i);
for (x = 0; x &lt; sibling.childNodes.length; x++) {
var sibling2 = sibling.childNodes.item(x);
if (sibling2.childNodes.length &gt; 0) {
var sibling3 = sibling2.childNodes.item(0);
alert(sibling3.data);
}
}
}
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</pre>
<img src ="http://www.blogjava.net/SunRiver/aggbug/124207.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/SunRiver/" target="_blank">Sun River</a> 2007-06-14 06:40 <a href="http://www.blogjava.net/SunRiver/archive/2007/06/14/124207.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ajax Faqs</title><link>http://www.blogjava.net/SunRiver/archive/2007/06/14/124206.html</link><dc:creator>Sun River</dc:creator><author>Sun River</author><pubDate>Wed, 13 Jun 2007 22:26:00 GMT</pubDate><guid>http://www.blogjava.net/SunRiver/archive/2007/06/14/124206.html</guid><description><![CDATA[<p><span style="COLOR: #0000ff">---Is there any way that an AJAX object can get back a record set?</span> </p>
Answer <br>
<p>You could build an XML document out of your recordset and send that back to the server, say you had a redord set for a "user" with the following details (name, surname, age, email), you could build an xml document like this:<br><br>Code:<br>&lt;recordset&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;user&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;Byron&lt;/name&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;surname&gt;Tymvios&lt;/surname&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;age&gt;25&lt;/age&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;email&gt;email@address.com&lt;/email&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;/user&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;user&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;User&lt;/name&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;surname&gt;Someone&lt;/surname&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;age&gt;39&lt;/age&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;email&gt;myAddy@address.com&lt;/email&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;/user&gt;<br>&lt;/recordset&gt;<br><br>You can add as many records as you have in your recordset, then once the client has received it you can use javascript to iterate over the &lt;user&gt;'s in the xml. </p>
<br><span style="COLOR: #0000ff">---Is it possible to set session variables from javascript?</span> <br>It's not possible to set any session variables directly from javascript as it is purely a client side technology. You can use AJAX though to asyncronously send a request to a servlet running on the server and then add the data to the session from within the servlet. So you wouldn't be using javascript to do the actual setting of session variables but it would look like it is.<br>&nbsp; I've been developing a sliding navigational menu. Here is how I save the state across pages:<br><br>
<pre><span style="FONT-SIZE: 12pt">var saveState = true;
if(saveState)
{
// This AJAX call will save the Navigator's state to session.
// We don't need a callback function because nothing happens
// once said state is saved.
var url = "AJAX_Servlet.aspx?function=saveNavigatorState&amp;control=" + id + "&amp;class=" + section.className + "";
req = new ActiveXObject("Microsoft.XMLHTTP");
req.open("POST", url, true);
req.send();
}
</span></pre>
<br><br><span style="FONT-SIZE: 12pt">Note that id is set to the Id of the submenu table (which is hidden / shown by other code which sets the className of the table. My stylesheet has css for each class.) earlier in the overal function. <br>Here is the codebehind for my AJAX_Servlet.aspx, which could easily be a web service:<br><br></span>
<pre><span style="FONT-SIZE: 12pt">private void Page_Load(object sender, System.EventArgs e)
{
if(Request.QueryString["function"] != null)
{
if(Request.QueryString["function"] == "saveNavigatorState")
SaveNavigatorState();
}
}
private void SaveNavigatorState()
{
if(Request.QueryString["control"] != null &amp;&amp; Request.QueryString["class"] != null)
{
string controlID = Request.QueryString["control"].ToString();
string className = Request.QueryString["class"].ToString();
Session[controlID] = className;
}
}
</span></pre>
<br><br>Then on my navigator codebehind, I just check for session data on load.<br>
<img src ="http://www.blogjava.net/SunRiver/aggbug/124206.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/SunRiver/" target="_blank">Sun River</a> 2007-06-14 06:26 <a href="http://www.blogjava.net/SunRiver/archive/2007/06/14/124206.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Something About Ajax </title><link>http://www.blogjava.net/SunRiver/archive/2007/06/14/124205.html</link><dc:creator>Sun River</dc:creator><author>Sun River</author><pubDate>Wed, 13 Jun 2007 19:31:00 GMT</pubDate><guid>http://www.blogjava.net/SunRiver/archive/2007/06/14/124205.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/SunRiver/archive/2007/06/14/124205.html'>阅读全文</a><img src ="http://www.blogjava.net/SunRiver/aggbug/124205.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/SunRiver/" target="_blank">Sun River</a> 2007-06-14 03:31 <a href="http://www.blogjava.net/SunRiver/archive/2007/06/14/124205.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>About Ajax (1)</title><link>http://www.blogjava.net/SunRiver/archive/2006/10/05/73449.html</link><dc:creator>Sun River</dc:creator><author>Sun River</author><pubDate>Thu, 05 Oct 2006 02:09:00 GMT</pubDate><guid>http://www.blogjava.net/SunRiver/archive/2006/10/05/73449.html</guid><description><![CDATA[
		<p>Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together in powerful new ways. Ajax incorporates:</p>
		<ul>
				<p>
				</p>
				<li>
						<a href="http://www.adaptivepath.com/publications/essays/archives/000266.php">standards-based presentation</a> using XHTML and CSS; 
</li>
				<li>dynamic display and interaction using the <a href="http://www.scottandrew.com/weblog/articles/dom_1">Document Object Model</a>; 
</li>
				<li>data interchange and manipulation using <a href="http://www-106.ibm.com/developerworks/xml/library/x-xslt/?article=xr">XML and XSLT</a>; 
</li>
				<li>asynchronous data retrieval using <a href="http://www.xml.com/pub/a/2005/02/09/xml-http-request.html">XMLHttpRequest</a>; 
</li>
				<li>and <a href="http://www.crockford.com/javascript/javascript.html">JavaScript</a> binding everything together. </li>
		</ul>
		<p>
				<font color="#ff1493">Questions:<br /></font>
				<br />- Entry level:<br />  - Is AJAX a <a class="iAs" style="COLOR: darkgreen; BORDER-BOTTOM: darkgreen 1px solid; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" href="http://www.experts-exchange.com/Programming/Q_21912424.html#" target="_blank" itxtdid="2549047"><font color="#000000">programming language</font></a><font color="#000000">?</font><br />  - What is AJAX?<br />  - How new is AJAX?<br />  - Why can/should AJAX be used?<br /> A: AJAX is best suited for small (hopefully unobtrusive) updates to the current<br />    web page, based on information that is not available until it has been provided<br />    by the end user.<br />  - When should AJAX NOT be used?<br />  A: It would not be appropriate to use AJAX when the "answer/result" can be determinded<br />    by the client.  Generally, the purpose of AJAX is to submit a short request to the server,<br />    and process the response in such a way as to add value to the currently displayed page.<br />    It would also not be appropriate to use AJAX when the magnitude of the response is such<br />    that it would be easier, and more clear to redisplay the page.<br /><br />  - What objects are used by AJAX <a class="iAs" style="COLOR: darkgreen; BORDER-BOTTOM: darkgreen 1px solid; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" href="http://www.experts-exchange.com/Programming/Q_21912424.html#" target="_blank" itxtdid="2549079">programs</a>?<br /><br />- Intermediate-level?<br />  - Describe the  formats and protocols used/specified by AJAX<br />  - Describe some things that can't be done with AJAX<br /> A: Sending a request to a server outside of the domain from which  the web page originated.<br />  - How should AJAX objects be created?<br />  - For what error conditions should programs check?<br />  - Are Finite State Machines (FSM's) appropriate for use with AJAX?<br />  - Identify and describe the state transitions that can/should occur within a transaction<br />A: - Reset : When the XmlHttpRequest object is created, no connection yet exists between the clent, and the server.<br />      Open  : When the xmlHttp.open() is issued, the request is being prepared for transmission to the server<br />      Sent   : When the xmlHttp.send() is issued, the request is transmitted to the server application<br />      Rcvd   : When the xmlHttp callback routine is called, the readyState and status fields of the object define why the routine was called<br /><br />Q. How do you know that an AJAX request has completed?<br />A. The XHR.readyState is 4 and the XHR.status is 200 (or zero if the request is to a local file). The callback function is called four times - first with status=1, then 2,3, and finally 4.<br />Q. How does XML processing differ on the different browsers?<br />A. It's an ActiveX object on IE, but is native on the other browsers<br />Q: What values exists for the XmlHttpRequest.readyState field, and what do they mean?<br />A: readyState values:<br />    0 = uninitialized<br />    1 = loading<br />    2 = loaded<br />    3 = interactive<br />    4 = complete   <br /><br /><br />Other areas to check up on:<br />   How do you process the returned XML data?<br />   If it's a Java/J2EE place: what about AJAX and JSF? <br />   How to populate the XML response on the <a class="iAs" style="COLOR: darkgreen; BORDER-BOTTOM: darkgreen 3px solid; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" href="http://www.experts-exchange.com/Programming/Q_21912424.html#" target="_blank" itxtdid="2551277">server</a>?<br />   How to terminate an active request?<br /><br /></p>
<img src ="http://www.blogjava.net/SunRiver/aggbug/73449.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/SunRiver/" target="_blank">Sun River</a> 2006-10-05 10:09 <a href="http://www.blogjava.net/SunRiver/archive/2006/10/05/73449.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ajax Beginners Tutorial</title><link>http://www.blogjava.net/SunRiver/archive/2006/09/24/71557.html</link><dc:creator>Sun River</dc:creator><author>Sun River</author><pubDate>Sun, 24 Sep 2006 05:24:00 GMT</pubDate><guid>http://www.blogjava.net/SunRiver/archive/2006/09/24/71557.html</guid><description><![CDATA[
		<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
				<tbody>
						<tr>
								<td class="container" valign="top">
										<table id="Table4" cellspacing="0" cellpadding="0" width="100%" border="0">
												<tbody>
														<tr>
																<td class="content">
																		<h2>
																				<font color="#000066" size="3">Using Ajax</font>
																		</h2>
																		<h3>
																				<font color="#000066" size="2">Page update without refresh using Javascript, PHP and XML's XMLHTTPRequest object (also known as 'remote scripting')</font>
																		</h3>
																		<p>In this tutorial we'll discuss the basic principles of remote scripting using Ajax, a combination of javascript and XML to allow web pages to be updated with new information from the server, without the user having to wait for a page refresh.  Ajax therefore allows us to build web applications with user interfaces rather more like those of desktop applications, providing a better experience for the user.  Ajax tools are becoming increasingly popular, and a list of ajax development projects is also given.</p>
																		<p>
																				<font color="#000000">
																						<strong>Here you'll find:</strong>
																				</font>
																		</p>
																		<ul>
																				<li>
																						<font color="#000000">
																								<strong>a brief tour of the important principles of Ajax</strong>
																						</font>
																				</li>
																				<li>
																						<font color="#000000">
																								<strong>code examples of all important points</strong>
																						</font>
																				</li>
																				<li>
																						<font color="#000000">
																								<strong>links to further Ajax and related resources</strong>
																						</font>
																				</li>
																		</ul>
																		<p>
																				<font color="#000000">This tutorial covers subjects which require some degree of familiarity with Javascript and PHP.  Beginners may therefore find it a little hard going, but hopefully should still be able to grasp the principles and uses of Ajax, if not the details.  There are some demos and further links at the bottom of the article and elsewhere on these pages - feel free to explore..</font>
																		</p>
																		<p>
																				<strong>
																						<font color="#000066">What is it?</font>
																				</strong>
																				<br />The standard and well-known method for user interaction with web-based applications involves the user entering information (e.g. filling out a form), submitting that information to the server, and awaiting a page refresh or redirect to return the response from the server.</p>
																		<p>This is at times frustrating for the user, besides being rather different to the 'desktop' style of user interface with which (s)he may be more familiar.</p>
																		<p>
																				<strong>Ajax</strong>
																				<strong>(Asynchronous Javascript And XML)</strong> is a technique (or, more correctly, a combination of techniques) for submitting server requests 'in the background' and returning information from the server to the user without the necessity of waiting for a page load.</p>
																		<p>Ajax is actually a combination of several technologies working together to provide this capability.</p>
																		<p>
																				<font color="#000066">
																						<strong>How does it work?</strong>
																				</font>
																				<br />Instead of a user request being made of the server via, for example, a normal HTTP POST or GET request, such as would be made by submitting a form or clicking a hyperlink, an Ajax script makes a request of a server by using the Javascript <strong>XMLHTTPRequest</strong> object.</p>
																		<p>Although this object may be unfamiliar to many, in fact it behaves like a fairly ordinary javascript object.  As you may well know, when using a javascript image object we may dynamically change the URL of the image source without using a page refresh. <strong>XMLHTTPRequest</strong> retrieves information from the server in a similarly invisible manner.</p>
																		<p>
																				<strong>
																						<font color="#000066">How is it coded?<br /></font>
																				</strong>There are a few, relatively simple, steps to coding an Ajax application.  The description below is an attempt to describe the salient points without bogging down the new user in too many of the technicalities.</p>
																		<p>
																				<strong>Firstly</strong>, we need to know how to <strong>create an XMLHTTPRequest object</strong>.  The process differs slightly depending on whether you are using Internet Explorer (5+) with ActiveX enabled, or a standards-compliant browser such as Mozilla Firefox.</p>
																		<p>With IE, the request looks like:</p>
																		<p align="center">
																				<font style="BACKGROUND-COLOR: #ffff99" color="#008000">
																						<font style="BACKGROUND-COLOR: #00ffff" color="#000000">
																								<font style="BACKGROUND-COLOR: #ffffff" color="#cc0000" size="2">http = new ActiveXObject("Microsoft.XMLHTTP");</font>
																						</font>
																				</font>
																		</p>
																		<font style="BACKGROUND-COLOR: #ffff99" color="#008000">
																				<font style="BACKGROUND-COLOR: #00ffff" color="#000000">
																						<p align="left">
																								<font style="BACKGROUND-COLOR: #ffffff" color="#000000">whereas in a standards-compliant browser we can instantiate the object directly:</font>
																						</p>
																						<p align="center">
																								<font size="2">
																										<font style="BACKGROUND-COLOR: #ffffff">
																												<font color="#cc0000">http = <strong>new</strong></font>
																										</font>
																										<font style="BACKGROUND-COLOR: #ffff99" color="#000000">
																												<font style="BACKGROUND-COLOR: #ffffff" color="#cc0000"> XMLHttpRequest();</font>
																										</font>
																										<br />
																								</font>
																						</p>
																				</font>
																		</font>
																		<p>There's an example of a short piece of code to create the object <a href="http://www.peej.co.uk/articles/rich-user-experience.html" target="_blank">here</a>, which clearly demonstrates the different approaches for the two different browser types, along with a browser detection routine.</p>
																		<p>
																				<strong>Secondly</strong>, we need to write an <strong>event handler</strong> which will be called via some event on our user's page, and will handle sending our request for data to our server.</p>
																		<p>The event handler will use various methods of our <strong>XMLHTTPRequest</strong> object to:</p>
																		<ul>
																				<li>make the request of the server 
</li>
																				<li>check when the server says that it has completed the request, and 
</li>
																				<li>deal with the information returned by the server </li>
																		</ul>
																		<p>We can make our request of the server by using a GET method to an appropriate server-side script.  Here's an example event handler called <strong>updateData</strong> which assumes that we have created our <strong>XMLHTTPRequest</strong> object and called it <strong>http</strong>:</p>
																		<p>
																				<font color="#990000">
																						<font size="2">
																								<strong>function</strong> updateData(param) {<br />  var myurl = [here I insert the URL to my server script]; </font>
																				</font>
																		</p>
																		<div style="DISPLAY: inline; BACKGROUND-COLOR: #ffff99">
																				<br />
																				<font color="#990000">
																						<font size="2">
																								<font style="BACKGROUND-COLOR: #ffffff">  </font>
																								<font style="BACKGROUND-COLOR: #ffffff">http.open("GET", myurl + "?id=" + escape(param), <strong>true</strong></font>
																						</font>
																				</font>
																				<font style="BACKGROUND-COLOR: #ffffff" color="#990000" size="2">);<br />  http.onreadystatechange = useHttpResponse;<br />  http.send(<strong>null</strong>);</font>
																		</div>
																		<br />
																		<font color="#990000" size="2">}</font>
																		<p> </p>
																		<p>
																				<font color="#000000">Note that the function listens to the <strong>onreadystatechange</strong> property of the <strong>XMLHTTPRequest</strong> object and, each time this parameter changes, calls a further function <strong>useHttpResponse</strong>.</font>
																		</p>
																		<p>You will note also that, for the sake of clarity, I have said little about the server-side script which is called - essentially this can be any server routine which will generate the required output when called with the relevant URL and appended parameters, as in any other HTTP GET request.  For the sake of the example we are passing a variable named <strong>id</strong> with a value <strong>param</strong> passed as an argument to the <strong>updateData</strong> function.</p>
																		<p>
																				<font color="#000000">
																						<strong>Thirdly</strong>, then, we need to write a function <strong>useHttpResponse</strong> which will establish when the server has completed our request, and do something useful with the data it has returned:</font>
																		</p>
																		<p>
																				<font style="BACKGROUND-COLOR: #ffffff" color="#990000" size="2">
																						<strong>function</strong>
																				</font>
																				<font style="BACKGROUND-COLOR: #ffffff" color="#990000" size="2"> useHttpResponse() {<br />  <strong>if</strong> (http.readyState == 4</font>
																				<font color="#990000">
																						<font size="2">
																								<font style="BACKGROUND-COLOR: #ffffff">) {<br /></font>
																								<font style="BACKGROUND-COLOR: #ffffff">    var textout = http.responseText;</font>
																								<br />
																								<font style="BACKGROUND-COLOR: #ffffff">    document.write.textout;</font>
																								<br />
																						</font>
																				</font>
																				<font style="BACKGROUND-COLOR: #ffffff" color="#990000" size="2">  }<br />}</font>
																		</p>
																		<p>
																				<font color="#000000">
																						<font style="BACKGROUND-COLOR: #ffffff" color="#000000">
																								<font style="BACKGROUND-COLOR: #ffffff" color="#000000">Note here that our</font> function checks for a <strong>readyState</strong> value of <strong>4</strong> - there are various numbered states describing the progress of such a request, but we are only interested in the value of 4, which indicates that the request is complete and we can use the returned data.</font>
																				</font>
																		</p>
																		<p>In this case, we have received our information as simple text via the <strong>responseText</strong> property of our <strong>XMLHTTPRequest</strong> object.  Information can, however, be returned as XML or as properties of a predefined javascript object, though this is perhaps beyond the scope of this tutorial.</p>
																		<p>Try out all the techniques described above in the <a onclick="javascript:window.open('ajaxdemo.php','demo','width€0,depthP0,scrollbars=yes,toolbar=no');" href="http://www.mousewhisperer.co.uk/ajax_page.html#">Ajax Demonstration</a></p>
																		<p>
																				<strong>
																						<font size="3">Making Ajax Easy</font>
																				</strong>
																		</p>
																		<p>There are quite a few toolkits springing up that package the Ajax calls into useable libraries.  For small projects, these may not be worth using due to the code overhead and learning curve involved, but for more complex Ajax projects you may find them useful.  You'll find some relevant links below and elsewhere on these pages - feel free to explore.</p>
																</td>
														</tr>
												</tbody>
										</table>
										<br />(From Ajaxprojects)</td>
								<td class="xr">
								</td>
						</tr>
						<tr>
								<td class="xbl">
								</td>
						</tr>
				</tbody>
		</table>
<img src ="http://www.blogjava.net/SunRiver/aggbug/71557.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/SunRiver/" target="_blank">Sun River</a> 2006-09-24 13:24 <a href="http://www.blogjava.net/SunRiver/archive/2006/09/24/71557.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>