OReilly AJAX hacks tips and tools for creating responsive websites mar 2006 ISBN 0596101694

725 39 0
  • Loading ...
1/725 trang
Tải xuống

Thông tin tài liệu

Ngày đăng: 26/03/2019, 16:30

AjaxHacks ByBruceW Perry Publisher:O'Reilly PubDate:March2006 PrintISBN-10:0-596-10169-4 PrintISBN-13:978-0-59-610169-5 Pages:438 TableofContents |Index Ajax,thepopulartermforAsynchronousJavaScriptandXML,isoneofthemostimportant combinationsoftechnologiesforwebdeveloperstoknowthesedays Withitsrich groupingoftechnologies,Ajaxdeveloperscancreateinteractivewebapplicationswith XML-basedwebservices,usingJavaScriptinthebrowsertoprocessthewebserver response TakingcompleteadvantageofAjax,however,requiressomethingmorethanyourtypical "how-to"book WhatitcallsforisAjaxHacksfromO'Reilly Thisvaluableguideprovides direct,hands-onsolutionsthattakethemysteryoutofAjax'smanycapabilities Eachhack representsacleverwaytoaccomplishaspecifictask,savingyoucountlesshoursof searchingfortherightanswer Asmartcollectionof100insidertipsandtricks,AjaxHackscoversallofthetechnology's finerpoints Wanttobuildnext-generationwebapplicationstoday?Thisbookcanshow youhow Amongthemultitudeoftopicsaddressed,itshowsyoutechniquesfor: UsingAjaxwithGoogleMapsandYahooMaps DisplayingWeather.comdata Scrapingstockquotes Fetchingpostalcodes Buildingwebformswithauto-completefunctionality AjaxHacksalsofeaturesanumberofadvancedhacksforacceleratedwebdevelopers Discoverhowtocreatehuge,maintainablebookmarklets,howtouseclient-sidestorage forAjaxapplications,andhowtocallabuilt-inJavaobjectfromJavaScriptusingAjax The bookevenaddressesbestpracticesfortestingAjaxapplicationsandimproving maintenance,performance,andreliabilityforJavaScriptcode ThelatestinO"Reilly'scelebratedHacksseries,AjaxHackssmartlycomplementsother O'ReillytitlessuchasHeadRushAjaxandJavaScript:TheDefinitiveGuide AjaxHacks ByBruceW Perry Publisher:O'Reilly PubDate:March2006 PrintISBN-10:0-596-10169-4 PrintISBN-13:978-0-59-610169-5 Pages:438 TableofContents |Index Foreword creditsCredits AbouttheAuthor Contributors Acknowledgments Preface BuildingSingle-PageApplications ExplainingAjax HowtoUseThisBook HowThisBookIsOrganized ConventionsUsedinThisBook UsingCodeExamples SafariEnabled HowtoContactUs GotaHack? Chapter1 AjaxBasics It'sNotaFloorWax HandlewithCare XMLHttpRequest Hack1 DetectBrowserCompatibilitywiththeRequestObject Hack2 UsetheRequestObjecttoPOSTDatatotheServer Hack3 UseYourOwnLibraryforXMLHttpRequest Hack4 ReceiveDataasXML Hack5 GetPlainOldStrings Hack6 ReceiveDataasaNumber Hack7 ReceiveDatainJSONFormat Hack8 HandleRequestObjectErrors Hack9 DigintotheHTTPResponse Hack10 GenerateaStyledMessagewithaCSSFile Hack11 GenerateaStyledUserMessageontheFly Chapter2 WebForms Hack12 SubmitTextFieldortextareaValuestotheServerWithoutaBrowser Refresh Hack13 DisplayTextFieldortextareaValuesUsingServerData Hack14 SubmitSelection-ListValuestotheServerWithoutaRoundTrip Hack15 DynamicallyGenerateaNewSelectionListUsingServerData Hack16 ExtendanExistingSelectionList Hack17 SubmitCheckboxValuestotheServerWithoutaRoundTrip Hack18 DynamicallyGenerateaNewCheckboxGroupwithServerData Hack19 PopulateanExistingCheckboxGroupfromtheServer Hack20 ChangeUnorderedListsUsinganHTTPResponse Hack21 SubmitHiddenTagValuestoaServerComponent Chapter3 Validation Hack22 ValidateaTextFieldortextareaforBlankFields Hack23 ValidateEmailSyntax Hack24 ValidateUniqueUsernames Hack25 ValidateCreditCardNumbers Hack26 ValidateCreditCardSecurityCodes Hack27 ValidateaPostalCode Chapter4 PowerHacksforWebDevelopers Hack28 GetAccesstotheGoogleMapsAPI Hack29 UsetheGoogleMapsAPIRequestObject Hack30 UseAjaxwithaGoogleMapsandYahoo!MapsMash-up Hack31 DisplayaWeather.comXMLDataFeed Hack32 UseAjaxwithaYahoo!MapsandGeoURLMash-up Hack33 DebugAjax-GeneratedTagsinFirefox Hack34 FetchaPostalCode Hack35 CreateLarge,MaintainableBookmarklets Hack36 UsePermanentClient-SideStorageforAjaxApplications Hack37 ControlBrowserHistorywithiframes Hack38 SendCookieValuestoaServerProgram Hack39 UseXMLHttpRequesttoScrapeanEnergyPricefromaWebPage Hack40 SendanEmailwithXMLHttpRequest Hack41 FindtheBrowser'sLocaleInformation Hack42 CreateanRSSFeedReader Chapter5 DirectWebRemoting(DWR)forJavaJocks Hack43 IntegrateDWRintoYourJavaWebApplication Hack44 UseDWRtoPopulateaSelectionListfromaJavaArray Hack45 UseDWRtoCreateaSelectionListfromaJavaMap Hack46 DisplaytheKeys/ValuesfromaJavaHashMaponaWebPage Hack47 UseDWRtoPopulateanOrderedListfromaJavaArray Hack48 AccessaCustomJavaObjectwithJavaScript Hack49 CallaBuilt-inJavaObjectfromJavaScriptUsingDWR Chapter6 HackAjaxwiththePrototypeandRicoLibraries Hack50 UsePrototype'sAjaxToolswithYourApplication Hack51 UpdateanHTMLElement'sContentfromtheServer Hack52 CreateObserversforWebPageFields Hack53 UseRicotoUpdateSeveralElementswithOneAjaxResponse Hack54 CreateaDrag-and-DropBookstore Chapter7 WorkwithAjaxandRubyonRails SensibleMVC Hack55 InstallRubyonRails Hack56 MonitorRemoteCallswithRails Hack57 MakeYourJavaScriptAvailabletoRailsApplications Hack58 DynamicallyGenerateaSelectionListinaRailsTemplate Hack59 FindOutWhetherAjaxIsCallingintheRequest Hack60 DynamicallyGenerateaSelectionListUsingDatabaseData Hack61 PeriodicallyMakeaRemoteCall Hack62 DynamicallyViewRequestInformationforXMLHttpRequest Chapter8 Savorthescript.aculo.usJavaScriptLibrary Hack63 Integratescript.aculo.usVisualEffectswithanAjaxApplication Hack64 CreateaLoginBoxThatShrugsOffInvalidLogins Hack65 CreateanAuto-CompleteFieldwithscript.aculo.us Hack66 CreateanIn-PlaceEditorField Hack67 CreateaWebFormThatDisappearsWhenSubmitted Chapter9 OptionsandEfficiencies Hack68 FixtheBrowserBackButtoninAjaxApplications Hack69 HandleBookmarksandBackButtonswithRSH Hack70 SetaTimeLimitfortheHTTPRequest Hack71 ImproveMaintainability,Performance,andReliabilityforLarge JavaScriptApplications Hack72 ObfuscateJavaScriptandAjaxCode Hack73 UseaDynamicscriptTagtoMakeWebServicesRequests Hack74 ConfigureApachetoDealwithCross-DomainIssues Hack75 RunaSearchEngineInsideYourBrowser Hack76 UseDeclarativeMarkupInsteadofScriptviaXForms Hack77 BuildaClient-SideCache Hack78 CreateanAuto-CompleteField Hack79 DynamicallyDisplayMoreInformationAboutaTopic Hack80 UseStringsandArraystoDynamicallyGenerateHTML Index Foreword Thetruthis,I'veneverbuiltanAjaxapplication Sure,I'veworkedonAjaxprojects Butwhenitcomesto programming,myexperienceisprettylimited I'vedonesome JavaScriptinghereandthere IknowalittlePerl,buthardly enoughtobuildawebapplication Asaprogrammer,I'mmore ofanoccasionalweekendhobbyistthananythingelse Youcanimaginehowfrustratingitisforpeopletolearnthisfact whentheysendmeemailsaskingforhelpwiththeirJavaScript Butyoucanhardlyfaultthemforexpectingmetobea technologist Afterall,Iwroteanarticlecoiningtheterm "Ajax,"andAjaxisallabouttechnology,right? ThefunnythingisthatIdidn'tseeitthatwaywhenIwas writingtheessay Ididn'tthinkIwaswritingfortechnologists atall I'madesigner,andIthoughtIwaswritingforadesign audience Ifyoulookatsomeoftheotherthingswe've publishedonadaptivepath.com,youcanseethatwe'remuch morelikelytobetalkingaboutwaystoanalyzeuserbehavioror makeanexperienceconnectwithpeoplethanaboutthelatest codelibrariesordataschemas That'sonereasonsomepeoplethoughtitwasalittlestrange formetobewritingaboutAjaxatall Designers,onewayof thinkinggoes,shouldleavewritingabouttechnologyto technologists ButseeingAjaxasapurelytechnologicalphenomenonmisses thepoint Ifanything,Ajaxisevenmoreofaseachangefor designersthanitisfordevelopers Sure,therearealotofways inwhichdevelopersneedtochangetheirthinkingastheymake thetransitionfrombuildingtraditionalwebapplicationsto buildingAjaxapplications Butforthoseofuswhodesignuser experiences,thechangebroughtaboutbyAjaxisevenmore profound We'vegottenprettygoodatourjobsinthelast10yearsorso We'vestartedtogetahandleonwhattheWebdoeswelland whattheWebdoespoorly Andwe'vedevelopedanarsenalof conventionstorelyonwhenwedesignapplications:wherethe logogoes,howalinkbehaveswhenitisclicked,howto communicatethatsomethingevencanbeclicked Allofthatknowledgewell,mostofit,anywaygoesoutthe windowwithAjax Wehaveawiderpalettetoworkwith,but thatalsomeanswehavemoreopportunitiestomakemistakes Andbelieveme,we'llmakealotofthem Ittakestimetoget smart,andjustasittookusawhiletogetahandleontheold staticWeb,it'lltakeussometimetogetgoodatcreatingAjax experiencesaswell Andthat'swhereyouandthisbookcomein OneofthemostinspiringthingsabouttheWebisthatanyone cancontributetoitsdevelopment Standardsbodiesand platformvendorsareimportant,ofcourse,butthereisno masterplanfortheevolutionoftheWeb TheWebgoeswhere itsuserswantittogobutonlywhenthey'reready Sometimes thatmeansagreatideadoesn'ttakeholdrightaway,and sometimesthatmeansitonlytakesonevoicetobringthatidea toanaudiencereadytohearit Allofus,designersanddeveloperstogether,arethearchitects oftheWeb Throughtoolslikethisbook,wecanlearnfrom eachother,andwecanuseourcreativitytospuronfurther innovation Thechoiceswemakenowlaythegroundworkfor whatistocome Atthismoment,Ajaxisourmanifestdestiny, theobviousnextchapterinthestoryoftheWeb Whenthis chapterisover,I'llbeexcitedtoseewhatthenextonebrings Butfornow,let'sseewhatwecandowithwhatwe'vegot Nowgetoutthere,andgethacking! JesseJamesGarrett SanFrancisco,CA December2005 Credits AbouttheAuthor Contributors Acknowledgments strings,datareceptionas XMLHttpRequestobject[SeeXMLHttpRequest object] requestvariable(JavaScript) request.overrideMimeType()function request.statusproperty2nd respvariable responsecodehandling2nd responseheaders responseIsFailure()function responseTextproperty responseXMLproperty restore()function RewriteRuledirective RFC2822 RichInternetApplications Rico drag-and-dropbookstore necessarylibraries updateofmultipleelementswithanAjaxrequest Javaservlets Rico.AjaxEngineobject Rollyo RoR(RubyonRails) scripttags a_complete()method actions[Seeactions] application.js callingJavaScriptapplications configurationfileforusewithMySQL controller distinguishingcallsbyXMLHttpRequestfromURLcalls dynamicviewingofXMLHttpRequestrequestinformation incrementaction installation One-ClickRubyInstaller makingperiodicremotecalls methodcalls MVCarchitecture partials remotecalls,monitoring render()method2nd selectionlists,dynamicgenerationusingdatabasedata show_envaction supporteddatabases templatecode2nd3rd4th templatesfordynamicselectionlistgeneration TimeZoneobject views webapplicationdirectorystructure webapplications,creating zero_updateaction RSH(ReallySimpleHistory) compatiblebrowsers RSS(ReallySimpleSyndication)feedreader format_rss_data()function get_rss_feed()function get_xml_file()function rss.html rss_parse.js Ruby RubyonRails[SeeRoR] Index [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O] [P][Q][R][S][T][U][V][W][X][Y][Z] Safariandiframes scraping scripttags webservicesrequestsusing script.aculo.us auto-completefields downloadwebsite in-placeeditorfields includedscriptfiles Prototypeand shakingloginboxoninvalidlogins visualeffects webformsthatdisappearonsubmission scriptaculous.js libraryimportation versions searchengines,runninginsideyourbrowser selectelement selectionlists creatingfromJavamapswithDWR dynamicgenerationfromdatabasedatausingRoR dynamicgenerationfromserverdata enablingusermodificationoption immediatesubmissiontoserver populatingfromJavaarraysusingDWR arrayvalues,gettingfromtheserver RoRtemplatesfordynamicgenerationof send()method sendData()function sendMessage()method sendSportsInfo()function servererrors,handling flooredservers problems,causesof unavailableservices wrongURL Set-Cookieheaders setHeader()method setProdCodes()function setQueryString()function setRequestHeader()function setSpan()function2nd setStyle()function setTimeout()method setupDates()function setupList()function setupSelect()function show_cache_info()function show_envacton showUpInfo()function single-pageapplications spaces,removingfromformfields spellcheckers statusproperty statusHandler()function statusTextproperty stockholdingvaluescript stockpricecollectingscript stringsplit()method stripExtraNumbers()function styleproperty styledmessages CSSfiles,generatingwith stylizeDiv()method submit_to_remote()method Index [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O] [P][Q][R][S][T][U][V][W][X][Y][Z] talkdrop.js technologiesusedinAjax textarea instantmessaginghackusing serverdata,displaywithoutbrowserrefreshes validation valuesubmissionswithoutbrowserrefreshes timesUp()function TimeZoneobject toggleeffect toggle()function toggle_visible()function el.style.displayattribute toGMTString()method toJSON()method toLocaleString()method toString()method tryblocks try/catch/finallystatement Index [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O] [P][Q][R][S][T][U][V][W][X][Y][Z] ultag ultags UniversalBrowserprivileges unmarshalling unorderedlists,modificationwithHTTPresponse updateResults()function uptime.html2nd usernames,validationof serverhandshake Index [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O] [P][Q][R][S][T][U][V][W][X][Y][Z] validation blankfields,checkingfor client-sidevalidation creditcardnumbers creditcardsecuritycodes spaces,removingfromformfields emailsyntax inline postalcodes usernames serverhandshake verify()function view views2nd Index [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O] [P][Q][R][S][T][U][V][W][X][Y][Z] W3C(WorldWideWebConsortium) WeatherForecasttable weather.com XMLfileofweatherinformation webAPIs webdevelopment AMASS[SeeAMASS] bookmarklets browserhistory,controllingwithiframes cookies GoogleMapsAPI[SeeGoogleMapsAPI] mash-ups[Seemash-ups] postalcodes,fetching weather.comXMLdatafeed,displaying pathinfo webforms checkboxes[Seecheckboxes] dataentrywithoutbrowserrefreshes hiddentagvalues,submissiontoaserver loggingsubmittedvalues serverdata,displaywithoutbrowserrefreshes trackingpageopenings unorderedlists,modificationwithHTTPresponse webpagefields,monitoringchangesin webpageupdateswithoutrefreshes webserveruptimevalue webservicesrequestswithdynamicscripttags web.xml WEBrick windowobject window.locationhash window.onload eventhandlerspecification window.onloadevent checkboxes,changesinstate window.onloadeventhandler2nd window.XMLHttpRequest Windows,RoRinstallationon wordsfile writeMap()function Index [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O] [P][Q][R][S][T][U][V][W][X][Y][Z] xf\\ repeatelement xfi.js XForms FormFacesengine XMLand XML(ExtensibleMarkupLanguage)2nd receptionofdataas XMLinstancedata xml_http_request?()method XMLHttpRequest2nd3rd[Seealsorequestobjects] asynchronousrequests browsercompatibiltydetection browserlocaleinformation,discovering calls,distinguishingfromRoRURLcalls customlibrariesforusing email,sendingwith EmailBeanobject sendMessage()method energyprices,scrapingfromwebpages MozillaFirefoximplementation settingatimelimitfor useacrossdomainswithApache XMLUtilsJavaclass XSLT(ExtensibleStylesheetLanguageandTransformation) Index [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O] [P][Q][R][S][T][U][V][W][X][Y][Z] Yahoo!MapsAPI applicationID mash-upwithGeoURL Index [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O] [P][Q][R][S][T][U][V][W][X][Y][Z] zipcodevalidation zoomlevel zoomvariable ... bookquestions @oreilly. com Thewebsite for Ajax Hacks listsexamples,errata, and plans for futureeditions Youcanfindthispageat: http://www .oreilly. com/catalog/ajaxhks/ For moreinformationaboutthisbook and others,seethe... Cookbook and Yahoo! Hacks, and totheACM'sCrossroads MarkPruettisaprogrammer and writerlivinginVirginia, whereheworks for aFortune500energycompany He's theauthoroftwobooks and numerousarticleson... newacronymssuchasAjaj(AsynchronousJavaScript and JSON) and lingosuchas"Ajaxy"(asinanAjaxyserver connection) Softwareinnovations and humanlanguageseemto sharethesameorganicdynamic Explaining Ajax Ajax Hacks waswrittenbyyourstruly and sevendifferent
- Xem thêm -

Xem thêm: OReilly AJAX hacks tips and tools for creating responsive websites mar 2006 ISBN 0596101694 , OReilly AJAX hacks tips and tools for creating responsive websites mar 2006 ISBN 0596101694 , Hack 1. Detect Browser Compatibility with the Request Object, Hack 2. Use the Request Object to POST Data to the Server, Hack 3. Use Your Own Library for XMLHttpRequest, Hack 4. Receive Data as XML, Hack 5. Get Plain Old Strings, Hack 6. Receive Data as a Number, Hack 7. Receive Data in JSON Format, Hack 8. Handle Request Object Errors, Hack 9. Dig into the HTTP Response, Hack 10. Generate a Styled Message with a CSS File, Hack 11. Generate a Styled User Message on the Fly, Hack 12. Submit Text Field or textarea Values to the Server Without a Browser Refresh, Hack 13. Display Text Field or textarea Values Using Server Data, Hack 14. Submit Selection-List Values to the Server Without a Round Trip, Hack 15. Dynamically Generate a New Selection List Using Server Data, Hack 16. Extend an Existing Selection List, Hack 17. Submit Checkbox Values to the Server Without a Round Trip, Hack 18. Dynamically Generate a New Checkbox Group with Server Data, Hack 19. Populate an Existing Checkbox Group from the Server, Hack 20. Change Unordered Lists Using an HTTP Response, Hack 21. Submit Hidden Tag Values to a Server Component, Hack 22. Validate a Text Field or textarea for Blank Fields, Hack 25. Validate Credit Card Numbers, Hack 26. Validate Credit Card Security Codes, Hack 27. Validate a Postal Code, Hack 28. Get Access to the Google Maps API, Hack 29. Use the Google Maps API Request Object, Hack 30. Use Ajax with a Google Maps and Yahoo! Maps Mash-up, Hack 32. Use Ajax with a Yahoo! Maps and GeoURL Mash-up, Hack 33. Debug Ajax-Generated Tags in Firefox, Hack 34. Fetch a Postal Code, Hack 35. Create Large, Maintainable Bookmarklets, Hack 36. Use Permanent Client-Side Storage for Ajax Applications, Hack 37. Control Browser History with iframes, Hack 38. Send Cookie Values to a Server Program, Hack 39. Use XMLHttpRequest to Scrape an Energy Price from a Web Page, Hack 40. Send an Email with XMLHttpRequest, Hack 41. Find the Browser's Locale Information, Hack 42. Create an RSS Feed Reader, Hack 43. Integrate DWR into Your Java Web Application, Hack 44. Use DWR to Populate a Selection List from a Java Array, Hack 45. Use DWR to Create a Selection List from a Java Map, Hack 46. Display the Keys/Values from a Java HashMap on a Web Page, Hack 47. Use DWR to Populate an Ordered List from a Java Array, Hack 48. Access a Custom Java Object with JavaScript, Hack 49. Call a Built-in Java Object from JavaScript Using DWR, Hack 50. Use Prototype's Ajax Tools with Your Application, Hack 51. Update an HTML Element's Content from the Server, Hack 52. Create Observers for Web Page Fields, Hack 53. Use Rico to Update Several Elements with One Ajax Response, Hack 54. Create a Drag-and-Drop Bookstore, Chapter 7. Work with Ajax and Ruby on Rails, Hack 55. Install Ruby on Rails, Hack 56. Monitor Remote Calls with Rails, Hack 57. Make Your JavaScript Available to Rails Applications, Hack 58. Dynamically Generate a Selection List in a Rails Template, Hack 59. Find Out Whether Ajax Is Calling in the Request, Hack 60. Dynamically Generate a Selection List Using Database Data, Hack 61. Periodically Make a Remote Call, Hack 62. Dynamically View Request Information for XMLHttpRequest, Hack 64. Create a Login Box That Shrugs Off Invalid Logins, Hack 66. Create an In-Place Editor Field, Hack 67. Create a Web Form That Disappears When Submitted, Hack 68. Fix the Browser Back Button in Ajax Applications, Hack 69. Handle Bookmarks and Back Buttons with RSH, Hack 70. Set a Time Limit for the HTTP Request, Hack 71. Improve Maintainability, Performance, and Reliability for Large JavaScript Applications, Hack 72. Obfuscate JavaScript and Ajax Code, Hack 73. Use a Dynamic script Tag to Make Web Services Requests, Hack 74. Configure Apache to Deal with Cross-Domain Issues, Hack 75. Run a Search Engine Inside Your Browser, Hack 76. Use Declarative Markup Instead of Script via XForms, Hack 77. Build a Client-Side Cache, Hack 78. Create an Auto-Complete Field, Hack 79. Dynamically Display More Information About a Topic, Hack 80. Use Strings and Arrays to Dynamically Generate HTML

Mục lục

Xem thêm

Gợi ý tài liệu liên quan cho bạn