-
AJAX and PHP.pdf下载
资源介绍
AJAX is a complex phenomenon that means different things to different people.
Computer users appreciate that their favorite websites are now friendlier and feel
more responsive. Web developers learn new skills that empower them to create sleek
web applications with little effort. Indeed, everything sounds good about AJAX!
At its roots, AJAX is a mix of technologies that lets you get rid of the evil page
reload, which represents the dead time when navigating from one page to another.
Eliminating page reloads is just one step away from enabling more complex features
into websites, such as real-time data validation, drag-and-drop, and other tasks
that weren't traditionally associated with web applications. Although the AJAX
ingredients are mature (the XMLHttpRequest object, which is the heart of AJAX,
was created by Microsoft in 1999), their new role in the new wave of web trends is
very young, and we'll witness a number of changes before these technologies will be
properly used to the best benefit of the end users.
AJAX isn't, of course, the answer to all the Web's problems, as the current hype
around it may suggest. As with any other technology, AJAX can be overused, or
used the wrong way. AJAX also comes with problems of its own: you need to fight
with browser inconsistencies, AJAX-specific pages don't work on browsers without
JavaScript, they can't be easily bookmarked by users, and search engines don't
always know how to parse them. Also, not everyone likes AJAX. While some are
developing enterprise architectures using JavaScript, others prefer not to use it at all.
When the hype is over, most will probably agree that the middle way is the wisest
way to go for most scenarios.
In AJAX and PHP: Building Modern Web Applications – Second Edition, we take a
pragmatic and safe approach by teaching relevant patterns and best practices that we
think any web developer will need sooner or later. We teach you how to avoid the
common pitfalls, how to write efficient AJAX code, and how to achieve functionality
that is easy to integrate into current and future web applications, without requiring
you to rebuild the whole solution around AJAX. You'll be able to use the knowledge
you learn from this book right away, in your PHP web applications.
What this book covers
Chapter 1: The World of AJAX and PHP is all about a quick introduction to the
world of AJAX. In order to proceed with learning how to build AJAX applications,
it's important to understand why and where they are useful. It describes the
XMLHttpRequest object, which is the key element that enables the client-side
JavaScript code to call a page on the server asynchronously.
Chapter 2: JavaScript and the AJAX Client walks you through many fields such as
working with HTML, JavaScript, CSS, the DOM, XML, and XMLHttpRequest.
It discusses the theory (and practice) that you will need to know to make these
components come together smoothly, and form a solid foundation for your future
AJAX applications. It also shows you how to implement simple error-handling
techniques, and how to write code efficiently.
Chapter 3: Object Oriented JavaScript covers a large area of what object-oriented
programming means in the world of JavaScript starting from basic features and
going far into the execution context of functions. It teaches you the basic OOP
concepts—encapsulation, polymorphism, and inheritance, how to work with
JavaScript objects, functions, classes, and prototypes, how to simulate private,
instance, and static class members in JavaScript, what the JavaScript execution
context is, how to implement inheritance by using constructor functions and
prototyping, and the basics of JSON.
Chapter 4: Using PHP and MySQL on the Server starts putting the server to work, using
PHP to generate dynamic output, and MySQL to manipulate and store the backend
data. This chapter shows you how to use XML and JSON with PHP (so that you
can create server-side code that communicates with your JavaScript client), how to
implement error-handling code in your server-side PHP code, and how to work with
MySQL databases.
Chapter 5: AJAX Form Validation creates a form validation application that
implements traditional techniques with added AJAX flavor, thereby making the form
more user-friendly, responsive, and pleasing. The intention of this chapter isn't to
build the perfect validation technique but, rather, a working proof of concept that
takes care of user input and ensures its validity.
Chapter 6: Debugging and Profiling AJAX Applications teaches how to enable and use
Internet Explorer's debugging capabilities. It shows how you can work with Web
Development Helper, Developer Toolbar, and other Internet Explorer tools and with
Firefox plugins such as Firebug, Venkman JavaScript Debugger, and Web Developer.
This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009
6393 south jamaica court, , englewood, , 80111
Preface
[ 3 ]
Chapter 7: Advanced Patterns and Techniques briefly covers some of the most important
patterns and techniques covering usability, security, and techniques. Looking at
methods, patterns, and techniques is so important that it has developed into its
own science and has created a set of guidelines for typical problems that offer us
predictable results.
Chapter 8: AJAX Chat with jQuery teaches how to use AJAX to easily implement
an online chat solution. This will also be your opportunity to use one of the most
important JavaScript frameworks around—jQuery. More precisely, this chapter will
explain the basics of jQuery and show how to create a simple, yet efficient client-
server chat mechanism using AJAX.
Chapter 9: AJAX Grid explains the usage of an AJAX-enabled data grid plugin, jqGrid.
Appendix: Preparing Your Working Environment covers the installation instructions
that set up your machine for the exercises in this book. It also covers preparing the
database that is used in many examples throughout the book.
What you need for this book
To go through the examples in this book you need PHP 5, a web server, and a
database server. We have tested the code under several environments, but mostly
with the Apache 2 web server, and MySQL 4.1 and MySQL 5 databases.
You can choose, however, to use another web server, or another database product, in
which case the procedures presented in the chapters might not be 100% accurate. It
is important to have PHP 5 or newer, because we use some features, such as Object
Oriented Programming support, which aren't available in older versions.
Please read the appendix for more details about setting up your machine. If your
machine already has the required software, you still need to read the final part of
appendix, where you are instructed about creating a database that is used for the
examples in this book.
Who this book is for
This book is written for PHP developers who want to learn how to use PHP,
JavaScript, MySQL, and jQuery to implement Web 2.0 applications, are looking
for a step-by-step, example-driven AJAX tutorial, want to learn advanced AJAX
coding patterns and techniques, and want to be able to assess the security and SEO
implications of their code.