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

In just a short time, you can learn how to use Ajax, JavaScript, and PHP to create interactive interfaces to your web ap

598 80 4MB

English Pages 367 Seiten + 1 CD-ROM [387] Year 2008;2009

Report DMCA / Copyright

DOWNLOAD FILE

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

Table of contents :
Cover......Page 1
Contents......Page 7
Introduction......Page 17
Part I: Web Basics Refresher......Page 23
A Short History of the Internet......Page 25
The World Wide Web......Page 26
Introducing HTTP......Page 30
The HTTP Request and Response......Page 31
HTML Forms......Page 33
Summary......Page 36
Introducing HTML......Page 37
Elements of an HTML Page......Page 39
A More Advanced HTML Page......Page 43
Some Useful HTML Tags......Page 45
Adding Your Own Style......Page 46
Add a Little class......Page 47
Applying Styles......Page 49
Formatting Text with Styles......Page 51
Adding Lines......Page 55
Summary......Page 56
The Need for Ajax......Page 57
Introducing Ajax......Page 59
The Constituent Parts of Ajax......Page 61
Putting It All Together......Page 63
Summary......Page 65
Part II: Introducing Web Scripting with JavaScript......Page 67
Tools for Scripting......Page 69
Displaying Time with JavaScript......Page 70
Adding JavaScript Statements......Page 71
Creating Output......Page 72
Adding the Script to a Web Page......Page 73
Testing the Script......Page 74
JavaScript Syntax Rules......Page 81
Using Comments......Page 82
Best Practices for JavaScript......Page 83
Summary......Page 85
Understanding Objects......Page 87
Understanding the Document Object Model (DOM)......Page 88
Working with Web Documents......Page 90
Accessing Browser History......Page 93
Working with the location Object......Page 94
Summary......Page 96
Using Variables......Page 97
Understanding Expressions and Operators......Page 101
Data Types in JavaScript......Page 102
Converting Between Data Types......Page 104
Using String Objects......Page 105
Working with Substrings......Page 108
Using Numeric Arrays......Page 110
Using String Arrays......Page 112
Sorting a Numeric Array......Page 114
Summary......Page 117
Using Functions......Page 119
Introducing Objects......Page 124
Using Objects to Simplify Scripting......Page 125
Extending Built-in Objects......Page 128
Summary......Page 131
CHAPTER 8: Controlling Flow with Conditions and Loops......Page 133
The if Statement......Page 134
Using Shorthand Conditional Expressions......Page 137
Testing Multiple Conditions with if and else......Page 138
Using Multiple Conditions with switch......Page 140
Using for Loops......Page 141
Using do…while Loops......Page 144
Working with Loops......Page 145
Looping Through Object Properties......Page 147
Summary......Page 150
Using the Math Object......Page 151
Working with Math Functions......Page 153
Using the with Keyword......Page 155
Working with Dates......Page 156
Using Third-Party Libraries......Page 159
Other Libraries......Page 160
Summary......Page 161
Part III: Introducing Ajax......Page 163
Introducing XMLHTTPRequest......Page 165
Creating the XMLHTTPRequest Object......Page 166
Summary......Page 172
Sending the Server Request......Page 173
Monitoring Server Status......Page 178
The Callback Function......Page 179
Summary......Page 182
The responseText and responseXML Properties......Page 183
Parsing responseXML......Page 187
Providing User Feedback......Page 188
Summary......Page 190
Constructing the Ajax Application......Page 191
The HTML Document......Page 192
Adding JavaScript......Page 193
Putting It All Together......Page 196
Summary......Page 200
Part IV: Server-side Scripting with PHP......Page 201
PHP Basics......Page 203
Your First PHP Script......Page 206
Summary......Page 210
Understanding Variables......Page 211
Data Types......Page 213
Working with Numbers......Page 214
Numeric Functions......Page 216
Working with Strings......Page 218
Formatting Strings......Page 219
String Functions......Page 221
Working with Arrays......Page 222
Array Functions......Page 224
Date Formats......Page 225
Working with Timestamps......Page 226
Summary......Page 229
Conditional Statements......Page 231
Loops......Page 236
Summary......Page 238
Using Functions......Page 239
Arguments and Return Values......Page 241
Summary......Page 245
Object-Oriented PHP......Page 247
What Is a Class?......Page 248
Creating and Using Objects......Page 249
Summary......Page 252
Part V: More Complex Ajax Technologies......Page 253
Getting More from the responseText Property......Page 255
Summary......Page 261
Introducing AHAH......Page 263
Creating a Small Library for AHAH......Page 264
Using myAHAHlib.js......Page 266
Summary......Page 271
Adding the “x” to Ajax......Page 273
The responseXML Property......Page 274
Project—An RSS Headline Reader......Page 278
Summary......Page 285
Introduction to Web Services......Page 287
REST—Representational State Transfer......Page 288
Using REST in Practice......Page 290
Web Services Using SOAP......Page 294
The SOAP Protocol......Page 295
Using Ajax and SOAP......Page 298
Reviewing SOAP and REST......Page 299
Summary......Page 300
An Ajax Library......Page 301
Reviewing myAHAHlib.js......Page 302
Implementing Our Library......Page 303
Using the Library......Page 306
Summary......Page 309
Common Ajax Errors......Page 311
The Back Button......Page 312
Making Ajax Degrade Elegantly......Page 313
Dealing with Search Engine Spiders......Page 314
Don’t Use Ajax Where It’s Inappropriate......Page 315
Test Code Across Multiple Platforms......Page 316
Some Programming Gotchas......Page 317
Summary......Page 318
Part VI: Ajax Tools and Resources......Page 319
Introducing prototype.js......Page 321
Wrapping XMLHTTPRequest—the Ajax Object......Page 324
Example Project—Stock Price Reader......Page 327
Summary......Page 329
Introducing Rico......Page 331
Rico’s Other Interface Tools......Page 336
Summary......Page 340
Downloading the Library......Page 341
Using Effects......Page 342
Building the Script......Page 343
Summary......Page 345
Introducing XOAD......Page 347
XOAD HTML......Page 350
Advanced Programming with XOAD......Page 353
Summary......Page 354
JavaScript Websites......Page 355
Web Development Sites......Page 356
Ajax Websites......Page 357
C......Page 359
E......Page 360
L......Page 361
S......Page 362
X......Page 363
Index......Page 365
A......Page 366
C......Page 367
D......Page 368
E......Page 369
F......Page 370
H......Page 371
I......Page 372
K - L......Page 373
M......Page 374
O......Page 375
P......Page 376
Q - R......Page 378
S......Page 379
V......Page 381
W......Page 382
Y - Z......Page 383

Polecaj historie