创建网站宝典英文文献翻译.doc

上传人:飞****2 文档编号:60126436 上传时间:2022-11-13 格式:DOC 页数:7 大小:41.50KB
返回 下载 相关 举报
创建网站宝典英文文献翻译.doc_第1页
第1页 / 共7页
创建网站宝典英文文献翻译.doc_第2页
第2页 / 共7页
点击查看更多>>
资源描述

《创建网站宝典英文文献翻译.doc》由会员分享,可在线阅读,更多相关《创建网站宝典英文文献翻译.doc(7页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、AjaxAjax is short for Asynchronous JavaScript and XML. It is cross-platform. It is effectively open source. It is supported by these versions of the major browsers: Internet Explorer 5.0 and up Netscape 7 and up Firefox, Opera 8+ Safari 1.2 and upAlthough it would be a stretch to call Ajax a new tec

2、hnology, and it is certainly not a programming language, it is an adaptive implementation of preexisting tools to provide an integrated, efficient new tool that can be used to make better, faster, more versatile Web applications.As you may know, Ajax, which is a mix or reformulation of existing tech

3、nologies, facilitates server interaction with elements of a Web page. This, in turn, results in a more responsive application with lower bandwidth usage, and, hence, lower costs, resulting in a win-win situation for all concerned. It is also these features that make it attractive to the so-called We

4、b 2.0 crowd and, those who are involved in software design and development for mobile handheld devices. Following are the major components of Ajax: JavaScript as the scripting language to call functions XMLHttpRequest is used for asynchronous data transfer from a server XHTML and Cascading Style She

5、ets (CSS) are used for uniform encoding and presentation cross-platform Document Object Model (DOM) is used for precise mapping and data display XML and XSLT (although, ironically, does not require use of XML for data fetch and transfer)Ajax provides that slight margin of advantage to get ahead of t

6、he competition. But you must know when to use it, and then use it judiciously. You would tend to defeat one of its appealing features fast, efficient downloads of small segments of data if you repeatedly called for updates or refreshes of information. You would constantly be tying up system resource

7、s with repeated calls for new data, which may not be new at all (or necessary). Would you, for example, find it necessary to refresh the temperature field every 3 seconds on a weather page? It could be better done where a refresh of that field is only done when the new temperature does not equal the

8、 old temperature. Async (asynchronous) just means that requests and data may be exchanged across the Internet from the client Web page to the server and back at any time. The JavaScript object used to do this is called XMLHttpRequest. However, there is no requirement that the asynchronous content be

9、 formatted in XML.Lets take a bit of a deeper look into the XMLHttpRequest object.XMLHttpRequestXMLHttpRequest is an object that has properties (which have values) and methods (which have values to be passed or implemented). Following are some uses of XMLHttpRequest that illustrate its lightning spe

10、ed: Instant translation This is to the extent that a concept such as a word is synchronously defined among the thousands of existing human languages. Smart shopping carts Allows the user to add, remove, or edit products instantly. Immediate saving of data Why force the user to click Submit when this

11、 object allows direct saving of data? Server/client side validation Allows you to validate data input on form controls as data is typed into each element.Because it is used to send and receive data to the server, the XMLHttpRequest object has three components or properties associated with each insta

12、nce of it: onreadystatechange readyState responseTextThe onreadystatechange property takes the value that has been returned by the server and stores it in the associated function(), which does the processing of the data returned by the server. This is a multistep process.The first step, the assignme

13、nt of the function to the onreadystatechange property, follows the standard assignment format:xmlHttp.onreadystatechange=function()Executable statementsExecuteThe executable statements within the onreadystatechange property are contained within a selection structure that accepts one of five values f

14、rom a server, each indicating a different state of the condition of the server in relation to the data request made. These returned values are stored within the readyState property. Each time the readyState property value changes, the onreadystatechange function() also executes. Those of you who are

15、 familiar with the OSI model might see a similarity to the request states and the analogous setup maintenance and teardown states of the Session Layer . . . or even Windowing.The current state of the object is determined by value in the readyState attribute. When there is a change (in other words, w

16、hen a state transition occurs), the value in this field changes as follows: The value of 0 would indicate that XMLHttpRequest object is in proper mode to beconstructed. A value of 1 allows the send method to set up headers and send them to the serverusing the send() method. A value of 2 indicates th

17、at the request to the server has been sent. A value of 3 indicates the server is processing the request. A value of 4 indicates that the data request is complete. This does not necessarily mean that the data has been successfully received. It almost certainly has, but, in the event that the unexpect

18、ed occurs, you will see a flagged message come up informing you of the failure. With the data successfully transferred from server to requestor object, you can then invoke the third property of the onreadystatechange object, which is the responseText property.When the readyState = 4 control of the p

19、rogram shifts downward, the actual data sent back from the server can be retrieved by the following generic syntax:Document.myForm.elementName=xmlHttp.responseText;This is then sent on to the Web page element that requested it without reloading the entire document. The responseText, of course, would

20、 be the response from the server in a string value.Ajax and the Mobile WebAjax may become a useful technology for mobile applications for the same reason that it is rapidly expanding in the more sedate market of desktop browsers: It is fast, efficient, bandwidthfriendly,and, because of this, will ha

21、ve cost benefits. Following is a list of browsers in themobile market that support the basic Ajax components of the XMLHttpRequest object and basic JavaScript is generally current: Internet Explorer Mobile (also known as Pocket Internet Explorer) Safari Mobile (iPhone) Opera Mobile newer than v. 8.x

22、, (but excludes Opera Mini) Minimo (Gecko-based) OpenWave newer than Mercury NetFront newer than v.3.4 BlazerHowever appealing the features of Ajax might be to the mobile browser market, use alone will not drive the market. Applications developed for mobile devices would synergistically drive growth

23、 and would help Ajax achieve an unrivalled dominance in the Mobile Web-browsing experience.There are advances in mobile devices that really minimize the bandwidth demands put on wireless browser communication. Using widgets (which are either the graphical interface on devices, or the slimmed-down ap

24、plication, including content, or a combination of both icon and application) that can be installed onto the mobile device via phone, this provides the focus and simplification required for ease of client use and ease of access to whichever applications are needed because so much of the content is pr

25、einstalled.In short, mobile widgets often use components of Ajax, namely the asynchronous data transfer. Some observers prognosticate that, since widgets for mobile devices use one of the key features of Ajax (async data transfer) and since iPhone (which is very popular) also uses Ajax-based widgets

26、, then usage is sure to grow.Ajax Quick ReferenceThe following provides a quick reference for key items discussed in this chapter: Ajax is composed of the existing technologies of HTML, JavaScript, XML, CSS, and asynchronous data transfer. XMLHttpRequest allows a Web page to communicate directly wit

27、h a server and update the page (page element) even after the page has been loaded. onreadystatechange property holds the latest value retrieved from the servers response to the readystate request sent out. These values can be 0 to 4, and reflect various states of readiness for the data request sent.

28、 xmlReq.open(Head, url, async, username, password) is the generic request format. xmlReq.send() is the generic send format. document.getElementById(someElement).innerHTML = xmlHttp.responseText; is used to send retrieved data to a Web page element for which the request was originated. Different brow

29、sers have different versions of the XMLHttpRequest object.Ajax是“异步JavaScript和XML”的简称。它是跨平台的开放源代码,为一下主流浏览器支持Internet Explorer 5.0及更高版本Netscape 7及更高版本Firefox及Opera 8Safari 1.2及更高版本尽管将Ajax称为一种新型技术有些勉强,它显然并不是一种编程语言,而是通过将现有工具改进提供一种集成而高效的新工具,从而创建更友好、更快捷和具有更多功能的Web应用程序。Ajax通过对一系列现有的相关技术重新整合,使服务器与Web页面元素的交互

30、更加方便。这样不仅得到了一个使用更少带宽并且响应更迅速的应用程序,而且降低了成本。这些功能使得Ajax对Web 2.0用户以及移动设备的设计和开发人员具有相当的吸引力。以下是Ajax的主要组件:JavaScript作为脚本语言用来调用函数。XMLHttpReques用于处理从服务器发出的异步数据传送。XHTML和层叠样式表(Cascading Style Sheets,CSS)用于统一编码以及跨平台呈现。文档对象模型(Document Object Model,DOM)用来产生精确映射和显示数据。XML和XSLT(XSLT并不需要使用XML来获取和传送数据)。Ajax在竞争中略显优势,但是必须

31、了解何时使用它以及如何正确地使用它。当反复更新或刷新信息时,会挑战到Ajax一个突出的功能快速高效地下载小的数据段。你可能需要不断地向系统重复请求新的数据,然而获得的数据可能根本不是新的。例如,在一个天气页面上每3秒刷新一次能获得当前的温度吗?只有在当前温度和过去温度不相同的情况下,这么做才有效。异步表述请求和数据可以在经由Internet从客户端Web页面至服务器并随时返回进行交换。完成以上任务的JavaScript对象称为XMLHttpRequest。不过,并不要求异步内容格式化为XML。下面来深入了解XMLHttpRequest对象。XMLHttpRequestXMLHttpReques

32、t是一个包含属性(该属性有相应的值)和方法(该方法包含将要传递或者实现的值)的对象。下面介绍一些关于XMLHttpRequest的应用:即时翻译这相当于用数以千计的人类语言同步定义一个概念(比如一个单词)。智能购物车允许用户即时添加、移除或编辑商品。即时存储数据它能够直接存储数据,而用户不必单击Submit(提交)按钮。服务器/客户端验证当数据被输入每个元素时,允许验证表单控件上输入的数据。由于XMLHttpRequest对象用来从服务器发送或接受数据,因此它包括3个与其每个实例相关的组件或属性:OnreadystatechangereadyStateresponseTextOnreadyst

33、atechange属性采用服务器返回的值,并将该值存储在function()(用来处理服务器返回的数据)函数中。这个过程包含以下步骤。第一步,为onreadystatechange属性指派函数,遵循以下标准的指派格式:xmlHttp.onreadystatechange=function()Executable statementsExecuteOnreadystatechange属性的可执行语句包含在一个选择结构中,该结构接受从服务器产生的5个值中的一个,每个值都代表一个与数据请求相关联的服务器条件状态。这些返回值存储在readyState属性中,每当readyState的值发生改变时,on

34、readystatechange function()就会执行。如果熟悉OSI模型的化,会发现这与请求状态、会话层的建立、拆卸状态,甚或窗口(Windowing)技术。对象的当前状态取决于readyState属性值。当发生改变(即状态发生变化)时,该字段中的值将发生下列变化:取值为0,表明XMLHttpRequest对象可以在适当的模式下被创建。取值为1,表明允许发送方法建立头并使用send()方法发送至服务器。取值为2,表明了至服务器的请求已经被发送。取值为3,表明服务器正在处理这个请求。取值为4,表明数据请求已经完成,这不等于数据已经被成功地接收。虽然在绝大多数情况下都是这样的,但发生异常

35、时将会看到一个数据请求失败的消息。一旦数据成功地从服务器传送至请求对象,便可以调用onreadystatechange对象的第3个属性responseText属性。当readyState4时,程序逆转,可以使用以下通用语法来检索从服务器返回的数据;Document.myForm.elementName=xmlHttp.responseText;然后数据会被发送至请求它的Web页面元素,而无须重载整个文档。毫无疑问,responseText将服务器响应作为字符串返回。Ajax和Mobile WebAjax有可能成为移动应用程序中一种非常有用的技术,它能够文件地在桌面浏览器市场中不断扩张在于:快速

36、、高效、少量带宽,从而节约了成本。下面是当前移动市场中的浏览器,它们支持XMLHttpRequest对象的基本Ajax组件和基本JavaScript: Internet Explorer Mobile (也称为Pocket Internet Explorer) Safari Mobile (iPhone) Opera Mobile,比v. 8.x更新的版本, (但除Opera Mini外) Minimo (基于Gecko) OpenWave,比Mercury更新的版本 NetFront ,比v.3.4更新的版本 Blazer尽管Ajax的功能对于移动浏览器市场具有相当的吸引力,但是单独应用它并

37、不足以驱动市场。移动设备应用程序的开发将有助于市场的增长,并且使Ajax在Mobile Web浏览市场中获得绝对的统治地位。移动设备的优势是真正最小化了无线浏览器通信的带宽需求。通过安装到移动设备上的小部件(设备上的图形接口或较小的应用程序,包括内容或图标和应用程序的组合),方便了用户使用和访问任何应用程序,因为大部分内容已经预安装了。简而言之,移动小部件经常会使用Ajax的组件,即异步数据传送。一些人预测,既然移动设备的小部件应用了Ajax的关键功能(异步数据传送),而且iPhone(它是非常流行的)也使用基于Ajax的小部件,那么Ajax的使用将越来越广泛。Ajax的快速参考下面是本章所讨

38、论的主要内容的快速参考: Ajax是由HTML、JavaScript、XML、层叠样式表(CSS)和异步数据传输等技术组成的。 XMLHttpRequest能够通过Web页面直接与服务器通信,并且在页面加载后更新这个页面(页面元素)。 Onreadystatechange属性能够保存从服务器对readystate发出请求的响应中检索的最新值。值可以是0到4之间的任何值,分别代表了发送的数据请求的不同状态。 xmlReq.open(Head,url,async,username,password)是通用的请求格式。xmlReq.send()是通用的发送格式。Document.getElementByld(someElement).innerHTML=xmlHttp.responseTe-xt;用来发送检索的数据至发起请求的Web页面元素。不同浏览器的XMLHttpRequest对象的版本有所不同。

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com