资源描述:
《ajax in action the role of the server》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、iTePub.Net-CollectTheroleoftheserverThischaptercovers■UsingcurrentwebframeworktypeswithAjax■Exchangingdatawiththeserverascontent,script,ordata■Communicatingupdatestotheserver■BundlingmultiplerequestsandrepliesintoasingleHTTPcall159LicensedtojonathanzhengiTePub.Net-C
2、ollect160CHAPTER5TheroleoftheserverThischapterconcludestheworkthatwestartedinchapter4:makingourapplica-tionsrobustandscalable.We’vemovedfromtheproof-of-conceptstagetosome-thingthatyoucanuseintherealworld.Chapter4examinedwaysofstructuringtheclientcodetoachieveourgoal;inthischapter,weloo
3、kattheserverand,morespe-cifically,atthecommunicationbetweentheclientandtheserver.We’llbeginbylookingatthebigpictureanddiscusswhatfunctionstheserverperforms.We’llthenmoveontodescribethetypesofarchitecturescommonlyemployedinserver-sideframeworks.Many,manywebframeworksareinusetoday,partic
4、ularlyintheJavaworld,andwewon’ttrytocoverthemall,butratherwe’llidentifycommonapproachesandwaysofaddressingwebapplicationdevelopment.Mostframeworksweredesignedtogenerateclassicwebapplica-tions,sowe’reparticularlyinterestedtoseehowtheyadapttoAjaxandwherethechallengeslie.Havingconsideredt
5、helarge-scalepatterns,we’lllookatthefinerdetailsofcommunicatingbetweenclientandserver.Inchapter2wecoveredthebasicsoftheXMLHttpRequestobjectandhiddenIFrames.We’llreturntothesebasicshereasweexaminethevariouspatternsforupdatingtheclientfromtheserveranddiscussthealternativestoparsingXMLdoc
6、umentsusingDOMmethods.Inthefinalsection,we’llpresentasystemformanagingclient/servertrafficoverthelife-timeoftheapplication,byprovidingaclient-sidequeueforrequestsandserver-sideprocessesformanagingthem.Let’sstartoff,then,bylookingattheroleoftheserverinAjax.5.1WorkingwiththeserversideInt
7、helifecycleofanAjaxapplication,theserverhastworolestofulfill,andthesearefairlydistinct.First,ithastodelivertheapplicationtothebrowser.Sofar,we’veassumedthattheinitialdeliveryofcontentisfairlystatic,thatis,wewritetheapplicationitselfasaseriesof.html,.css,and.jsfilesthatevenaverybasicw