ajax英文文献Word文档下载推荐.doc
- 文档编号:13159947
- 上传时间:2022-10-07
- 格式:DOC
- 页数:9
- 大小:137KB
ajax英文文献Word文档下载推荐.doc
《ajax英文文献Word文档下载推荐.doc》由会员分享,可在线阅读,更多相关《ajax英文文献Word文档下载推荐.doc(9页珍藏版)》请在冰豆网上搜索。
XMLHttpRequest;
WebApplications
I.INTRODUCTION
AjaxisshorthandforAsynchronousJavaScriptandXML(andDHTML,andsoon).ThephrasewascoinedbyJesseJamesGarrettofAdaptivePathandis,accordingtoJesse,notmeanttobeanacronym.However,Ajaxisfarmorethanjustafad;
it'
sapowerfulapproachtobuildingWebsitesandit'
snotnearlyashardtolearnasanentirenewlanguage.
Figure1.Thetraditionalmodelforwebapplications(left)comparedtotheAjaxmodel(right)
Ajaxisn’tatechnology.It’sreallyseveraltechnologies,eachflourishinginitsownright,comingtogetherinpowerfulnewways.Ajaxincorporates:
.standards-basedpresentationusingXHTMLandCSS;
.dynamicdisplayandinteractionusingtheDocumentObjectModel;
.datainterchangeandmanipulationusingXMLandXSLT;
.asynchronousdataretrievalusingXMLHttpRequest;
.JavaScriptbindingeverythingtogether.
Theclassicwebapplicationmodelworkslikethis:
MostuseractionsintheinterfacetriggeranHTTPrequestbacktoawebserver.Theserverdoessomeprocessing—retrievingdata,crunchingnumbers,talkingtovariouslegacysystems—andthenreturnsanHTMLpagetotheclient.It’samodeladaptedfromtheWeb’soriginaluseas
ahypertextmedium,butasfansoftheElementsofUserExperienceknow,whatmakestheWebgoodforhypertextdoesn’tnecessarilymakeitgoodforsoftwareapplications.
Thisapproachmakesalotoftechnicalsense,butitdoesn’tmakeforagreatuserexperience.Whiletheserverisdoingitsthing,what’stheuserdoing?
That’sright,waiting.Andateverystepinatask,theuserwaitssomemore.Obviously,wewouldn’tmakeuserswaitaroundindesigningtheWebfromscratchforapplications.Onceaninterfaceisloaded,whyshouldtheuserinteractioncometoahalteverytimetheapplicationneedssomethingfromtheserver?
Infact,whyshouldtheuserseetheapplicationgototheserveratall?
II.MAKEASYNCHRONOUSREQUESTSWITH
JAVASCRIPTANDAJAX
MostWebapplicationsusearequest/responsemodelthatgetsanentireHTMLpagefromtheserver.Theresultisaback-and-forththatusuallyinvolvesclickingabutton,waitingfortheserver,clickinganotherbutton,andthenwaitingsomemore.WithAjaxandtheXMLHttpRequestobject,wecanusearequest/responsemodelthatneverleavesuserswaitingforaservertorespond.
A.IntroducingXMLHttpRequestXMLHttpRequesthasactuallybeenaroundinseveralbrowsersforquiteawhile,whichisthekeytoWeb2.0,Ajax,andprettymucheverything.Togiveareallyquickoverview,thesearejustafewofthemethodsandpropertieswillbeusedonthisobject:
.open():
Setsupanewrequesttoaserver.
.send():
Sendsarequesttoaserver.
.abort():
Bailsoutofthecurrentrequest.
.readyState:
ProvidesthecurrentHTMLreadystate.
.responseText:
Thetextthattheserversendsbacktorespondtoarequest.
Eachofthesemethodsandpropertiesrelatetosendingarequestanddealingwitharesponse.Infact,ifwesaweverymethodandpropertyofXMLHttpRequest,theywouldallrelatetothatverysimplerequest/responsemodel.Soclearly,wewon'
tlearnaboutanamazingnewGUIobjectorsomesortofsuper-secretapproachtocreatinguserinteraction;
programmerswillworkwithsimplerequestsandsimpleresponses.Itmightnotsoundexciting,butcarefuluseofthisoneobjectcantotallychangeourapplications.
First,weneedtocreateanewvariableandassignittoaninstanceoftheXMLHttpRequestobject.That'
sprettysimpleinJavaScript,justusethenewkeywordwiththeobjectname,likeinFig.2.
Figure2.CreateanewXMLHttpRequestobject
Inreallife,thingscangowrongandthiscodedoesn'
tprovideanyerror-handling.Aslightlybetterapproachistocreatethisobjectandhaveitgracefullyfailifsomethinggoeswrong.Forexample,manyolderbrowsers(believeitornot,peoplearestillusingoldversionsofNetscapeNavigator)don'
tsupportXMLHttpRequestandWebapplicationsneedtoletthoseusersknowthatsomethinghasgonewrong.Fig.3showshowtocreatethisobjectsoifsomethingfails,itthrowsoutaJavaScriptalert.
Figure3.CreateXMLHttpRequestwithsomeerror-handlingabilities
ItturnsoutthatMicrosoftsupportsAjax,butcallsitsversionofXMLHttpRequestsomethingdi
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ajax 英文 文献
![提示](https://static.bdocx.com/images/bang_tan.gif)