Home > Store > Open Source > Ajax & JavaScript

Sams Teach Yourself Ajax, JavaScript, and PHP All in One

Register your product to gain access to bonus material or receive a coupon.

Sams Teach Yourself Ajax, JavaScript, and PHP All in One

eBook (Watermarked)

  • Your Price: $25.59
  • List Price: $31.99
  • Includes EPUB, MOBI, and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    MOBI MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Description

  • Copyright 2009
  • Pages: 384
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-13-264998-5
  • ISBN-13: 978-0-13-264998-8

In just a short time, you can learn how to use Ajax, JavaScript, and PHP to create interactive interfaces to your web applications by combining these powerful technologies.

No previous Ajax programming experience is required. Using a straightforward, step-by-step approach, each lesson in this book builds on the previous ones, enabling you to learn the essentials of Ajax programming with JavaScript, PHP, and related technologies from the ground up.

Regardless of whether you run Linux, Windows, or Mac OS X, the enclosed CD includes a complete Ajax programming starter kit that gives you all the programming tools, reference information, JavaScript libraries, and server software you need to set up a stable environment for learning, testing, and production.

Learn how to…

  • Build better, more interactive interfaces for your web applications
  • Make JavaScript, HTML, XML, and PHP work together to create Ajax effects
  • Compile an Ajax application
  • Create and consume web services with SOAP and REST
  • Avoid common errors and troubleshoot programs
  • Use popular Ajax libraries to speed up and improve common programming tasks

On the CD

  • XAMPP for Windows, Mac OS X, and Linux—an easy-to-install package to set up a PHP- and MySQL-enabled Apache server on your computer
  • The jEdit programming editor for Windows, Mac, and Linux
  • Prototype, Scriptaculous, Rico, and XOAD—popular JavaScript libraries for creating Ajax applications and effects
  • A complete Ajax, HTML, XML, and PHP tutorial reference library in searchable PDF format
  • Source code for the examples in the book

Phil Ballard is a software engineering consultant and developer specializing in website and intranet design and development for an international portfolio of clients. He has an honors degree from the University of Leeds, England, and has worked for several years in commercial and managerial roles in the high technology sector.

Michael Moncur is a freelance webmaster and author. He runs a network of websites and has written several bestselling books about web development, networking, certification programs, and databases.

Category: Web Development

Covers: Ajax, JavaScript and PHP

User Level: Beginning–Intermediate 

Sample Content

Table of Contents

Introduction

Part I: Web Basics Refresher                                                                         7

Chapter 1: Workings of the Web                                                               9

    A Short History of the Internet........................................................... 9

    The World Wide Web..................................................................... 10

    Introducing HTTP............................................................................ 14

    The HTTP Request and Response................................................... 15

    HTML Forms.................................................................................. 17

    Summary......................................................................................... 20

chapter 2: Writing and Styling Pages in HTML and CSS                         21

    Introducing HTML.......................................................................... 21

    Elements of an HTML Page............................................................. 23

    A More Advanced HTML Page...................................................... 27

    Some Useful HTML Tags................................................................ 29

    Adding Your Own Style.................................................................. 30

    Defining the Rules............................................................................ 31

    Add a Little class............................................................................. 31

    Applying Styles................................................................................ 33

    Formatting Text with Styles.............................................................. 35

    Adding Lines................................................................................... 39

    Summary......................................................................................... 40

Chapter 3: Anatomy of an Ajax Application                                             41

    The Need for Ajax.......................................................................... 41

    Introducing Ajax.............................................................................. 43

    The Constituent Parts of Ajax.......................................................... 45

    Putting It All Together...................................................................... 47

    Summary......................................................................................... 49

Part II: Introducing Web Scripting with JavaScript                                        51

chapter 4: Creating Simple Scripts in JavaScript                                      53

    Tools for Scripting........................................................................... 53

    Displaying Time with JavaScript....................................................... 54

    Beginning the Script......................................................................... 55

    Adding JavaScript Statements.......................................................... 55

    Creating Output............................................................................... 56

    Adding the Script to a Web Page..................................................... 57

    Testing the Script............................................................................. 58

    JavaScript Syntax Rules................................................................... 65

    Using Comments............................................................................. 66

    Best Practices for JavaScript............................................................ 67

    Summary......................................................................................... 69

chapter 5: Working with the Document Object Model (DOM)                71

    Understanding Objects.................................................................... 71

    Understanding the Document Object Model (DOM)........................ 72

    Working with Web Documents........................................................ 74

    Accessing Browser History.............................................................. 77

    Working with the location Object..................................................... 78

    Summary......................................................................................... 80

chapter 6: Using Variables, Strings, and Arrays                                       81

    Using Variables............................................................................... 81

    Understanding Expressions and Operators....................................... 85

    Data Types in JavaScript................................................................. 86

    Converting Between Data Types...................................................... 88

    Using String Objects........................................................................ 89

    Working with Substrings.................................................................. 92

    Using Numeric Arrays..................................................................... 94

    Using String Arrays.......................................................................... 96

    Sorting a Numeric Array.................................................................. 98

    Summary....................................................................................... 101

chapter 7: Using Functions and Objects                                                103

    Using Functions............................................................................. 103

    Introducing Objects....................................................................... 108

    Using Objects to Simplify Scripting................................................ 109

    Extending Built-in Objects.............................................................. 112

    Summary....................................................................................... 115

chapter 8: Controlling Flow with Conditions and Loops                         117

    The if Statement............................................................................. 118

    Using Shorthand Conditional Expressions....................................... 121

    Testing Multiple Conditions with if and else..................................... 122

    Using Multiple Conditions with switch............................................ 124

    Using for Loops............................................................................. 125

    Using while Loops......................................................................... 128

    Using do…while Loops................................................................. 128

    Working with Loops...................................................................... 129

    Looping Through Object Properties............................................... 131

    Summary....................................................................................... 134

chapter 9: Using Built-In Functions and Libraries                                   135

    Using the Math Object................................................................... 135

    Working with Math Functions........................................................ 137

    Using the with Keyword................................................................ 139

    Working with Dates....................................................................... 140

    Using Third-Party Libraries............................................................ 143

    Other Libraries.............................................................................. 144

    Summary....................................................................................... 145

Part III: Introducing Ajax                                                                           147

chapter 10: The Heart of Ajax–the XMLHTTPRequest Object           149

    Introducing XMLHTTPRequest..................................................... 149

    Creating the XMLHTTPRequest Object........................................ 150

    Summary....................................................................................... 156

chapter 11: Talking with the Server                                                       157

    Sending the Server Request........................................................... 157

    Monitoring Server Status............................................................... 162

    The Callback Function................................................................... 163

    Summary....................................................................................... 166

chapter 12: Using the Returned Data                                                     167

    The responseText and responseXML Properties............................ 167

    Parsing responseXML................................................................... 171

    Providing User Feedback.............................................................. 172

    Summary....................................................................................... 174

Chapter 13: Our First Ajax Application                                                  175

    Constructing the Ajax Application.................................................. 175

    The HTML Document................................................................... 176

    Adding JavaScript......................................................................... 177

    Putting It All Together.................................................................... 180

    Summary....................................................................................... 184

Part IV: Server-side Scripting with PHP                                                     185

Chapter 14: Getting to Know PHP                                                        187

    PHP Basics................................................................................... 187

    Your First PHP Script................................................................... 190

    Summary....................................................................................... 194

chapter 15: Variables                                                                            195

    Understanding Variables................................................................ 195

    Data Types.................................................................................... 197

    Working with Numbers.................................................................. 198

    Numeric Data Types...................................................................... 200

    Numeric Functions......................................................................... 200

    Working with Strings..................................................................... 202

    Formatting Strings.......................................................................... 203

    String Functions............................................................................. 205

    Working with Arrays..................................................................... 206

    Array Functions............................................................................. 208

    Date Formats................................................................................ 209

    Working with Timestamps.............................................................. 210

    Summary....................................................................................... 213

Chapter 16: Flow Control                                                                      215

    Conditional Statements.................................................................. 215

    Loops........................................................................................... 220

    Summary....................................................................................... 222

Chapter 17: Functions                                                                           223

    Using Functions............................................................................. 223

    Arguments and Return Values........................................................ 225

    Using Library Files......................................................................... 229

    Summary....................................................................................... 229

Chapter 18: Using Classes                                                                     231

    Object-Oriented PHP.................................................................... 231

    What Is a Class?........................................................................... 232

    Creating and Using Objects........................................................... 233

    Summary....................................................................................... 236

Part V: More Complex Ajax Technologies                                                 237

Chapter 19: Returning Data as Text                                                       239

    Getting More from the responseText Property................................ 239

    Summary....................................................................................... 245

Chapter 20: AHAH–Asynchronous HTML and HTTP                         247

    Introducing AHAH........................................................................ 247

    Creating a Small Library for AHAH............................................... 248

    Using myAHAHlib.js..................................................................... 250

    Summary....................................................................................... 255

Chapter 21: Returning Data as XML                                                      257

    Adding the “x” to Ajax................................................................... 257

    The responseXML Property.......................................................... 258

    Project–An RSS Headline Reader............................................... 262

    Summary....................................................................................... 269

chapter 22: Web Services and the REST and SOAP Protocols             271

    Introduction to Web Services......................................................... 271

    REST–Representational State Transfer......................................... 272

    Using REST in Practice.................................................................. 274

    Web Services Using SOAP........................................................... 278

    The SOAP Protocol...................................................................... 279

    Using Ajax and SOAP................................................................... 282

    Reviewing SOAP and REST.......................................................... 283

    Summary....................................................................................... 284

chapter 23: A JavaScript Library for Ajax                                             285

    An Ajax Library............................................................................ 285

    Reviewing myAHAHlib.js.............................................................. 286

    Implementing Our Library.............................................................. 287

    Using the Library........................................................................... 290

    Summary....................................................................................... 293

chapter 24: Ajax Gotchas                                                                     295

    Common Ajax Errors.................................................................... 295

    The Back Button........................................................................... 296

    Bookmarking and Links................................................................. 297

    Telling the User That Something Is Happening................................ 297

    Making Ajax Degrade Elegantly..................................................... 297

    Dealing with Search Engine Spiders................................................ 298

    Pointing Out Active Page Elements................................................. 299

    Don’t Use Ajax Where It’s Inappropriate...................................... 299

    Security......................................................................................... 300

    Test Code Across Multiple Platforms............................................. 300

    Ajax Won’t Cure a Bad Design..................................................... 301

    Some Programming Gotchas.......................................................... 301

    Summary....................................................................................... 302

Part VI: Ajax Tools and Resources                                                            303

Chapter 25: The prototype.js Toolkit                                                     305

    Introducing prototype.js................................................................. 305

    Wrapping XMLHTTPRequest–the Ajax Object........................... 308

    Example Project–Stock Price Reader.......................................... 311

    Summary....................................................................................... 313

chapter 26: Using Rico                                                                         315

    Introducing Rico............................................................................ 315

    Rico’s Other Interface Tools.......................................................... 320

    Summary....................................................................................... 324

Chapter 27: Using Script.aculo.us                                                          325

    Downloading the Library................................................................ 325

    Including the Files.......................................................................... 326

    Using Effects................................................................................. 326

    Building the Script.......................................................................... 327

    Summary....................................................................................... 329

Chapter 28: Using XOAD                                                                     331

    Introducing XOAD........................................................................ 331

    XOAD HTML.............................................................................. 334

    Advanced Programming with XOAD............................................. 337

    Summary....................................................................................... 338

Appendix: JavaScript, PHP, and Ajax Websites                                     339

Glossary                                                                                              343

TOC, 0672329654, 6/6/2008

Updates

Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership