网页设计外文翻译---使用XMLHttpRequest对象
《网页设计外文翻译---使用XMLHttpRequest对象》由会员分享,可在线阅读,更多相关《网页设计外文翻译---使用XMLHttpRequest对象(13页珍藏版)》请在毕设资料网上搜索。
1、Using the XMLHttpRequest Object Now that weve discussed the history of dynamic Web applications and introduced Ajax, its 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, Go
2、ogle Suggest and Ta-da List wouldnt exist as we currently know them. And you wouldnt be reading this book! XMLHttpRequest was originally implemented in Internet Explorer 5 as an ActiveX component. That it worked only in Internet Explorer kept most developers from using XMLHttpRequest until its recen
3、t adoption as a de facto standard in Mozilla 1.0 and Safari 1.2. Its 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
4、 from browser to browser, though most methods and properties are widely supported. Currently, Firefox, Safari, Opera, Konqueror, and Internet Explorer all implement the behavior of the XMLHttpRequest object similarly. That said, if a significant number of your users still access your site or applica
5、tion with older browsers, you will need to consider your options. As we discussed in Chapter 1, if you are going to use Ajax techniques, you need to either develop an alternative site or allow your application to degrade gracefully. With most usage statistics indicating that only a small fraction of
6、 browsers in use today lack XMLHttpRequest support, the chances of this being a problem are slim. However, you need to check your Web logs and determine what clients your customers are using to access your sites. Overview of the XMLHttpRequest Object You must first create an XMLHttpRequest object us
7、ing JavaScript before you can use the object to send requests and process responses. Since XMLHttpRequest is not a W3C standard, you can use JavaScript in a couple of ways to create an instance of XMLHttpRequest. Internet Explorer implements XMLHttpRequest as an ActiveX object, and other browsers su
8、ch as Firefox, Safari, and Opera implement it as a native JavaScript object. Because of these differences, the JavaScript code must contain logic to create an instance of XMLHttpRequest using the ActiveX technique or using the native JavaScript object technique. The previous statement might send shi
9、vers down the spines of those who remember the days when the implementation of JavaScript and the DOM varied widely among browsers. Fortunately, in this case you dont need elaborate code to identify the browser type to know how to create an instance of the XMLHttpRequest object. All you need to do i
10、s check the browsers support of ActiveX objects. If the browser supports ActiveX objects, then you create the XMLHttpRequest object using ActiveX. Otherwise, you create it using the native JavaScript object technique. If the call to window.ActiveXObjectfails, then the JavaScript branches to the else
11、statement, which determines whether the browser implements XMLHttpRequest as a native JavaScript object. If window.XMLHttpRequestexists, then an instance of XMLHttpRequest is created. Thanks to JavaScripts dynamically typed nature and that XMLHttpRequest implementations are compatible across various
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中设计图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 网页 设计 外文 翻译 使用 xmlhttprequest 对象
