【正文】
e field matures, the best ones will bee apparent. Some of the more mature libraries include libXmlRequest, RSLite, sarissa,JavaScript Object Notation (JSON), JSRS, Direct Web Remoting (DWR), and Ruby on Rails. This is a dynamic space, so keep your RSS aggregator tuned to those sites dedicated to posting about all things Ajax! Summary While Ajaxesque techniques have been used for many years, the recent adoption of the XMLHttpRequest object by modern browsers has ushered in a new era of developing rich Web applications. In this chapter, we established the basics of working with the heart of Ajax, the XMLHttpRequest object. At this point, you know the methods and properties of the XMLHttpRequest object, and we’ve shown you some simple examples of their use. As you can see, the object is pretty straightforward and hides much of its plexity from you. Combined with a healthy dose of JavaScript and some basic DOM manipulation, Ajax allows for a level of interactivity previously unmatched on the Web. 英文翻譯 使用 XMLHttpRequest 對象 我們已經(jīng)討論了動態(tài) Web 應(yīng)用的發(fā)展歷史,并簡要介紹了 Ajax,下面再來討論問題的關(guān)鍵:如何使用 XMLHttpRequest 對象。 In general, the various frameworks and toolkits available on the Web take care of the basic wiring and the browser abstractions, and some add user interface ponents. Some are purely client based。 2. An instance of the XMLHttpRequest object is created. Using the open() method, the call is set up— the URL is set along with the desired HTTP method, typically GETor POST. The request is actually triggered via a call to the send() method. 3. A request is made to the server. This might be a call to a servlet, a CGI script, or any serverside technique. 4. The server can do anything you can think of, including accessing a data store or even another system. 5. The request is returned to the browser. The ContentTypeis set to text/xml— the XMLHttpRequest object can process results only of the text/html type. In more plex instances, the response might be quite involved and include JavaScript, DOM manipulation, or other related technologies. Note that you also need to set the headers so that the browser will not cache the results locally. You do this with the following code: (CacheControl, nocache)。Using the XMLHttpRequest Object Now that we’ve discussed the history of dynamic Web applications and introduced Ajax, it’s time to cover the heart of the matter: how to use the XMLHttpRequest object. While Ajax is more of a technique than a technology, without widespread support for XMLHttpRequest, Google Suggest and Tada List wouldn’t exist as we currently know them. And you wouldn’t be reading this book! XMLHttpRequest was originally implemented in Inter Explorer 5 as an ActiveX ponent. That it worked only in Inter Explorer kept most developers from using XMLHttpRequest until its recent adoption as a de facto standard in Mozilla and Safari . It’s important to note that XMLHttpRequest is not a W3C standard, though much of the functionality is covered in a new proposal: the DOM Level 3 Load and Save Specification. Because it is not a standard, its behavior may differ slightly from browser to browser, though most methods and properties are widely supported. Currently, Firefox, Safari, Opera, Konqueror, and Inter Explorer all implement the behavior of the XMLHttpRequest object similarly. That said, if a significant number of your users still access your site or application with older browsers, you will need to consider your