下载
加入VIP
  • 专属下载券
  • 上传内容扩展
  • 资料优先审核
  • 免费资料无限下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 AJAX and PHP - Building Modern Web Applications

AJAX and PHP - Building Modern Web Applications.pdf

AJAX and PHP - Building Modern …

megabox
2012-12-21 0人阅读 举报 0 0 0 暂无简介

简介:本文档为《AJAX and PHP - Building Modern Web Applicationspdf》,可适用于IT/计算机领域

AJAXandPHPBuildingModernWebApplications–SecondEditionBuilduserfriendlyWebApplicationswithJavaScriptandPHPBogdanBrinzareaIamandiCristianDarieAudraHendrixBIRMINGHAMMUMBAIAJAXandPHPBuildingModernWebApplications–SecondEditionCopyright©PacktPublishingAllrightsreservedNopartofthisbookmaybereproduced,storedinaretrievalsystem,ortransmittedinanyformorbyanymeans,withoutthepriorwrittenpermissionofthepublisher,exceptinthecaseofbriefquotationsembeddedincriticalarticlesorreviewsEveryefforthasbeenmadeinthepreparationofthisbooktoensuretheaccuracyoftheinformationpresentedHowever,theinformationcontainedinthisbookissoldwithoutwarranty,eitherexpressorimpliedNeithertheauthors,norPacktPublishing,anditsdealersanddistributorswillbeheldliableforanydamagescausedorallegedtobecauseddirectlyorindirectlybythisbookPacktPublishinghasendeavoredtoprovidetrademarkinformationaboutallofthecompaniesandproductsmentionedinthisbookbytheappropriateuseofcapitalsHowever,PacktPublishingcannotguaranteetheaccuracyofthisinformationFirstpublished:DecemberProductionReference:PublishedbyPacktPublishingLtdLincolnRoadOltonBirmingham,BPA,UKISBNwwwpacktpubcomCoverImagebyParagKadam(paragvkadamgmailcom)CreditsAuthorsBogdanBrinzareaIamandiCristianDarieAudraHendrixReviewerKalpeshBarotAcquisitionEditorDouglasPatersonDevelopmentEditorDhirajChandiramaniTechnicalEditorAanchalKumarIndexerRekhaNairEditorialTeamLeaderGagandeepSinghProjectTeamLeaderLataBasantaniProjectCoordinatorsSrimoyeeGhoshalRajashreeHamineProofreaderSandraHopperGraphicsNileshMohiteProductionCoordinatorsAdlineSwethaJesuthasDollyDasilvaCoverWorkDollyDasilvaAbouttheAuthorsBogdanBrinzareaIamandiisasoftwareengineerhavingastrongbackgroundinComputerScienceHeholdsaMasterandBachelorDegreefromtheAutomaticControlandComputersFacultyatthePolitehnicaUniversityofBucharest,RomaniaHealsohasanAuditordiplomafromtheComputerSciencedepartmentatEcolePolytechnique,Paris,FranceHismaininterestsincludesoftwarearchitecture,webtechnologies,distributedcomputing,andsoftwaremethodologiesCurrently,heistheSoftwareDevelopmentManagerataRomanianbank,BancaRomaneasca,amemberoftheNationalBankofGreece,wherehecoordinatesthedevelopmentandimplementationofenterprisesoftwareforthebankingindustryHeisalsotheauthorofthebooksAJAXandPHP:BuildingResponsiveWebApplicationsandMicrosoftAJAXLibraryEssentials:ClientsideASPNETAJAXExplainedCristianDarieisasoftwareengineerwithexperienceinawiderangeofmoderntechnologies,andistheauthorofnumerousbooks,whicharealllistedonhishomepageathttp:wwwcristiandarieroCristianisthemanagerandtheformertechnicalarchitectofhttp:wwwokaziiro,thelargestRomanianecommercewebsiteAudraHendrixwaseducatedatNorthwesternUniversitySheworksasaconsultantinappliedtechnologyandmarketingtosmallandmediumsizedbusinessesWhileherclientlistincludesFortunecompanies,shepreferstheflexibility,agility,andchallengesofsmalltomediumsizedbusinessesShehasconsultedbothintheUnitedStatesandFranceforbusinessesseekingtobetterutilizetheirresourcesandmaximizetheirgainsbyreinventingandreapplyingbackofficeandInternetapplications,datamanagement,costeffectivemarketingstrategies,staffingrequirements,andplanninganddeploymentofneworemergingproductlinesAspecialthanksgoesouttomydaughter,ZsaZsaanunendingandjoyfulsourceofinspirationandboundlessloveYouare,byfar,mygreatestachievementAbouttheReviewerKalpeshBarothasaboutfiveyearsofexperienceintheworldofPHPHehasworkedextensivelyonsmallandlargescalesocialnetworkingwebsitesdevelopedinPHPHehasbeeninvolvedinvariedprojects,fromplanninganddevelopingwebsitestocreatingcustommodulesonbigsocialnetworkingwebsitesHereceivedaMastersdegreeinEnterpriseSoftwareEngineeringfromUniversityofGreenwich,UKTherehelearnedthetheorybehindhiscomputerexperienceandbecameamuchmoreefficientcomputerprogrammerHehasworkedactivelyintheITsectorsincehisfreshmanyearattheuniversityHehasbeenaPHPdevelopersincethenandhasdevelopedhisskillsinthisfieldThroughhisincreasingresponsibilities,hehaslearnedtoprioritizeneedsandwants,andappliesthisabilitytohisprojectsHehasactedasatechnicalreviewerforOOPwithPHPforPacktPublishingIwouldliketothankmywife,BansariBarot,forhercontinuedsupportinallmyprojectsandRajashreeHamineforherconstanteffortsinremindingmetoreviewthechaptersontimeTableofContentsPrefaceChapter:TheWorldofAJAXandPHPThebigpictureAJAXandWebBuildingwebsitessinceHTTPandHTMLPHPandotherserversidetechnologiesJavaScriptandotherclientsidetechnologiesWhat'smissingTheworldofAJAXWhatisAJAXmadeofUsesandmisusesofAJAXResourcesandtoolsSettingupyourenvironmentBuildingasimpleapplicationwithAJAXandPHPSummaryChapter:JavaScriptandtheAJAXClientJavaScriptandtheDocumentObjectModelJavaScripteventsandtheDOMEvenmoreDOMJavaScript,DOM,andCSSUsingtheXMLHttpRequestobjectCreatingtheXMLHttpRequestobjectJavaScriptexceptionhandlingCreatingbetterobjectsforInternetExplorerInitiatingserverrequestsusingXMLHttpRequestHandlingserverresponseTableofContentsiiWorkingwithXMLstructuresHandlingmoreerrorsandthrowingexceptionsCreatingXMLstructuresSummaryChapter:ObjectOrientedJavaScriptWhyisOOPinJavaScriptimportantObjectorientedprogrammingconceptsEncapsulationInheritancePolymorphismObjectorientedprogrammingwithJavaScriptJavaScriptobjectsaredictionariesJavaScriptfunctionsJavaScriptfunctionsarefirstclassobjectsInnerfunctionsClosuresJavaScriptclassesConstructorsClassdiagramsReferencingexternalfunctionsPrototypeobjectsInstancemethodsandpropertiesStaticmethodsandpropertiesPrivatemembersTheJavaScriptexecutioncontextvarx,thisx,andxUsingtherightcontextJavaScriptOOPinpractice:IntroducingJSONJSONconceptsAsimpleJSONexampleSummaryChapter:UsingPHPandMySQLontheServerPHP,DOM,andXMLPHPandJSONPassingparametersandhandlingPHPerrorsWorkingwithMySQLCreatingdatabasetablesManipulatingdataConnectingtoyourdatabaseandexecutingqueriesSummaryTableofContentsiiiChapter:AJAXFormValidationImplementingAJAXformvalidationXMLHttpRequest,versionAJAXformvalidationSummaryChapter:DebuggingandProfilingAJAXApplicationsDebuggingandprofilingwithInternetExplorerEnablingdebugginginInternetExplorerandDebugginginInternetExplorerOtherInternetExplorerdebuggingtoolsDebuggingandprofilingwithFirefoxFirebugVenkmanJavaScriptdebuggerWebDeveloperSummaryChapter:AdvancedPatternsandTechniquesPredictivefetchingpatternProgressindicatorpatternUnobtrusiveJavaScriptProgressiveenhancementandgracefuldegradationAsynchronousfileuploadwithAJAXHTTPandhowfileuploadworksIframeforasynchronousfileuploadwithAJAXCrossdomaincallsCrossdomaincallsusingaserverproxyCrossdomaincallsusingFlashCrossdomaincallsusingiframesCrossdomaincallsusingJSONPCrosssiterequestforgeryJSONhijackingMitigationsofCSRFCrosssitescriptingExploitsNonpersistentXSSPersistentXSSMitigationsofXSSInputvalidationEscapingCookiessecuritySummaryTableofContentsivChapter:AJAXChatwithjQueryChattingusingAJAXjQueryBeforewegetstartedThefirststepsjQueryDOMSelectorsjQuerywrapperobjectMethodchainingEventhandlingAsimpleexampleBasicconceptsAJAXchatThechatapplicationSummaryChapter:AJAXGridImplementingtheAJAXdatagridCodeoverviewThedatabaseStylesandcolorsTheserversideCreatingthegrid,stepbystepSummaryAppendix:PreparingYourWorkingEnvironmentInstallingXAMPPInstallingXAMPPonWindowsInstallingXAMPPonLinuxPreparingtheAJAXdatabaseIndexPrefaceAJAXisacomplexphenomenonthatmeansdifferentthingstodifferentpeopleComputerusersappreciatethattheirfavoritewebsitesarenowfriendlierandfeelmoreresponsiveWebdeveloperslearnnewskillsthatempowerthemtocreatesleekwebapplicationswithlittleeffortIndeed,everythingsoundsgoodaboutAJAX!Atitsroots,AJAXisamixoftechnologiesthatletsyougetridoftheevilpagereload,whichrepresentsthedeadtimewhennavigatingfromonepagetoanotherEliminatingpagereloadsisjustonestepawayfromenablingmorecomplexfeaturesintowebsites,suchasrealtimedatavalidation,draganddrop,andothertasksthatweren'ttraditionallyassociatedwithwebapplicationsAlthoughtheAJAXingredientsaremature(theXMLHttpRequestobject,whichistheheartofAJAX,wascreatedbyMicrosoftin),theirnewroleinthenewwaveofwebtrendsisveryyoung,andwe'llwitnessanumberofchangesbeforethesetechnologieswillbeproperlyusedtothebestbenefitoftheendusersAJAXisn't,ofcourse,theanswertoalltheWeb'sproblems,asthecurrenthypearounditmaysuggestAswithanyothertechnology,AJAXcanbeoverused,orusedthewrongwayAJAXalsocomeswithproblemsofitsown:youneedtofightwithbrowserinconsistencies,AJAXspecificpagesdon'tworkonbrowserswithoutJavaScript,theycan'tbeeasilybookmarkedbyusers,andsearchenginesdon'talwaysknowhowtoparsethemAlso,noteveryonelikesAJAXWhilesomearedevelopingenterprisearchitecturesusingJavaScript,othersprefernottouseitatallWhenthehypeisover,mostwillprobablyagreethatthemiddlewayisthewisestwaytogoformostscenariosInAJAXandPHP:BuildingModernWebApplications–SecondEdition,wetakeapragmaticandsafeapproachbyteachingrelevantpatternsandbestpracticesthatwethinkanywebdeveloperwillneedsoonerorlaterWeteachyouhowtoavoidthecommonpitfalls,howtowriteefficientAJAXcode,andhowtoachievefunctionalitythatiseasytointegrateintocurrentandfuturewebapplications,withoutrequiringyoutorebuildthewholesolutionaroundAJAXYou'llbeabletousetheknowledgeyoulearnfromthisbookrightaway,inyourPHPwebapplicationsPrefaceWhatthisbookcoversChapter:TheWorldofAJAXandPHPisallaboutaquickintroductiontotheworldofAJAXInordertoproceedwithlearninghowtobuildAJAXapplications,it'simportanttounderstandwhyandwheretheyareusefulItdescribestheXMLHttpRequestobject,whichisthekeyelementthatenablestheclientsideJavaScriptcodetocallapageontheserverasynchronouslyChapter:JavaScriptandtheAJAXClientwalksyouthroughmanyfieldssuchasworkingwithHTML,JavaScript,CSS,theDOM,XML,andXMLHttpRequestItdiscussesthetheory(andpractice)thatyouwillneedtoknowtomakethesecomponentscometogethersmoothly,andformasolidfoundationforyourfutureAJAXapplicationsItalsoshowsyouhowtoimplementsimpleerrorhandlingtechniques,andhowtowritecodeefficientlyChapter:ObjectOrientedJavaScriptcoversalargeareaofwhatobjectorientedprogrammingmeansintheworldofJavaScriptstartingfrombasicfeaturesandgoingfarintotheexecutioncontextoffunctionsItteachesyouthebasicOOPconceptsencapsulation,polymorphism,andinheritance,howtoworkwithJavaScriptobjects,functions,classes,andprototypes,howtosimulateprivate,instance,andstaticclassmembersinJavaScript,whattheJavaScriptexecutioncontextis,howtoimplementinheritancebyusingconstructorfunctionsandprototyping,andthebasicsofJSONChapter:UsingPHPandMySQLontheServerstartsputtingtheservertowork,usingPHPtogeneratedynamicoutput,andMySQLtomanipulateandstorethebackenddataThischaptershowsyouhowtouseXMLandJSONwithPHP(sothatyoucancreateserversidecodethatcommunicateswithyourJavaScriptclient),howtoimplementerrorhandlingcodeinyourserversidePHPcode,andhowtoworkwithMySQLdatabasesChapter:AJAXFormValidationcreatesaformvalidationapplicationthatimplementstraditionaltechniqueswithaddedAJAXflavor,therebymakingtheformmoreuserfriendly,responsive,andpleasingTheintentionofthischapterisn'ttobuildtheperfectvalidationtechniquebut,rather,aworkingproofofconceptthattakescareofuserinputandensuresitsvalidityChapter:DebuggingandProfilingAJAXApplicationsteacheshowtoenableanduseInternetExplorer'sdebuggingcapabilitiesItshowshowyoucanworkwithWebDevelopmentHelper,DeveloperToolbar,andotherInternetExplorertoolsandwithFirefoxpluginssuchasFirebug,VenkmanJavaScriptDebugger,andWebDeveloperPrefaceChapter:AdvancedPatternsandTechniquesbrieflycoverssomeofthemostimportantpatternsandtechniquescoveringusability,security,andtechniquesLookingatmethods,patterns,andtechniquesissoimportantthatithasdevelopedintoitsownscienceandhascreatedasetofguidelinesfortypicalproblemsthatofferuspredictableresultsChapter:AJAXChatwithjQueryteacheshowtouseAJAXtoeasilyimplementanonlinechatsolutionThiswillalsobeyouropportunitytouseoneofthemostimportantJavaScriptframeworksaroundjQueryMoreprecisely,thischapterwillexplainthebasicsofjQueryandshowhowtocreateasimple,yetefficientclientserverchatmechanismusingAJAXChapter:AJAXGridexplainstheusageofanAJAXenableddatagridplugin,jqGridAppendix:PreparingYourWorkingEnvironmentcoverstheinstallationinstructionsthatsetupyourmachinefortheexercisesinthisbookItalsocoverspreparingthedatabasethatisusedinmanyexamplesthroughoutthebookWhatyouneedforthisbookTogothroughtheexamplesinthisbookyouneedPHP,awebserver,andadatabaseserverWehavetestedthecodeunderseveralenvironments,butmostlywiththeApachewebserver,andMySQLandMySQLdatabasesYoucanchoose,however,touseanotherwebserver,oranotherdatabaseproduct,inwhichcasetheprocedurespresentedinthechaptersmightnotbeaccurateItisimportanttohavePHPornewer,becauseweusesomefeatures,suchasObjectOrientedProgrammingsupport,whicharen'tavailableinolderversionsPleasereadtheappendixformoredetailsaboutsettingupyourmachineIfyourmachinealreadyhastherequiredsoftware,youstillneedtoreadthefinalpartofappendix,whereyouareinstructedaboutcreatingadatabasethatisusedfortheexamplesinthisbookWhothisbookisforThisbookiswrittenforPHPdeveloperswhowanttolearnhowtousePHP,JavaScript,MySQL,andjQuerytoimplementWebapplications,arelookingforastepbystep,exampledrivenAJAXtutorial,wanttolearnadvancedAJAXcodingpatternsandtechniques,andwanttobeabletoassessthesecurityandSEOimplicationsoftheircodePrefaceConventionsInthisbook,youwillfindanumberofstylesoftextthatdistinguishbetweendifferentkindsofinformationHerearesomeexamplesofthesestyles,andanexplanationoftheirmeaningCodewordsintextareshownasfollows:"Wecanincludeothercontextsthroughtheuseoftheincludedirective"Ablockofcodeissetasfollows:createthesecond<ui>elementandaddatextnodetoitoLiOrange=documentcreateElement("li")oOrange=documentcreateTextNode("Orange")oLiOrangeappendChild(oOrange)Whenwewishtodrawyourattentiontoaparticularpartofacodeblock,therelevantlinesoritemsaresetinbold:createthesecond<ui>elementandaddatextnodetoitoLiOrange=documentcreateElement("li")oOrange=documentcreateTextNode("Orange")oLiOrangeappendChild(oOrange)Anycommandlineinputoroutputiswrittenasfollows:tarxvfzxampplinuxXYZtargzCoptNewtermsandimportantwordsareshowninboldWordsthatyouseeonthescreen,inmenusordialogboxesforexample,appearinthetextlikethis:"NowclickontheStartDebuggingbuttonIfyoureceiveaconfirmationwindowlikethatinthefollowingscreenshot,clickonOK"WarningsorimportantnotesappearinaboxlikethisTipsandtricksappearlikethisPrefaceReaderfeedbackFeedbackfromourreadersisalwayswelcomeLetusknowwhatyouthinkaboutthisbookwhatyoulikedormayhavedislikedReaderfeedbackisimportantforustodeveloptitlesthatyoureallygetthemostoutofTosendusgeneralfeedback,simplysendanemailtofeedbackpacktpubcom,andmentionthebooktitleviathesubjectofyourmessageIfthereisabookthatyouneedandwouldliketoseeuspublish,pleasesendusanoteintheSUGGESTATITLEformonwwwpacktpubcomoremailsuggestpacktpubcomIfthereisatopicthatyouhaveexpertiseinandyouareinterestedineitherwritingorcontributingtoabookon,seeourauthorguideonwwwpacktpubcomauthorsCustomersupportNowthatyouaretheproudownerofaPacktbook,wehaveanumberofthingstohelpyoutogetthemostfromyourpurchaseDownloadingtheexamplecodeforthebookVisithttp:wwwpacktpubcomfilescodeCodeziptodirectlydownloadtheexamplecodeThedownloadablefilescontaininstructionsonhowtousethemErrataAlthoughwehavetakeneverycaretoensuretheaccuracyofourcontent,mistakesdohappenIfyoufindamistakeinoneofourbooksmaybeamistakeinthetextorthecodewewouldbegratefulifyouwouldreportthistousBydoingso,youcansaveotherreadersfromfrustration,andhelpustoimprovesubsequentversionsofthisbookIfyoufindanyerrata,pleasereportthembyvisitinghttp:wwwpacktpubcomsupport,selectingyourbook,clickingontheletusknowlink,andenteringthedetailsofyourerrataOnceyourerrataareverified,yoursubmissionwillbeacceptedandtheerrataaddedtoanylistofexistingerrataAnyexistingerratacanbeviewedbyselectingyourtitlefromhttp:wwwpacktpubcomsupportPrefacePiracyPiracyofcopyrightmaterial

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

评分:

/49

VIP

意见
反馈

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利