Book Image

PHP Ajax Cookbook

Book Image

PHP Ajax Cookbook

Overview of this book

Table of Contents (16 chapters)
PHP Ajax Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Ajax is the necessary paradigm in Web 2.0 sites. Most Web 2.0 sites are built with PHP and Ajax. Extending Ajax is about delivering front-end services for accessing back-end services in PHP in a quick and easy manner. With this book in hand, you will learn how to use the necessary tools for Ajaxification of websites and iPhones.

The PHP Ajax Cookbook will teach you how to use the combination of PHP and Ajax as a powerful platform for websites or web applications. Using Ajax for communication with the server leads to faster response with PHP at the back-end services. The combination of Ajax and PHP has many features such as speeding up the user experience, giving your web client much quicker response time, and letting the client browser retrieve data from the server without having to refresh the whole page. You will learn the nuances of optimization and debugging Ajax applications. Further, you will learn how to program Ajax on iPhone devices.

This book will teach you popular selector-based JavaScript followed by important concepts on debugging, optimization, and best practices. There is a collection of recipes focused on creating basic utilities such as validating forms using Ajax and creating a five-star rating system. As jQuery is quite popular, useful tools and jQuery plugins like Ajax tooltips, tab navigation, autocomplete, shopping cart, and Ajax chat are covered subsequently. By the end of Chapter 7 you will learn to visually speed up website responsiveness and build SEO-friendly Ajax websites. You will also get to know about all popular Ajax webservices and APIs like Twitter, Facebook and Google Maps, which are covered in Chapter 8, Ajax Mashups. Finally, step-by-step recipes are presented to build iPhone apps using basic libraries and everyday useful Ajax tools.

Build rich, interactive Web 2.0 sites with rich standards and Mashups around PHP Ajax.

What this book covers

Chapter 1, Ajax Libraries, teaches us how to work with the most famous JavaScript libraries and frameworks with capabilities of Ajax functionality. These libraries were selected by our subjective opinion and we are not trying to say which library/framework is better or worse. Each of them has its advantages and disadvantages.

Chapter 2 , Basic Utilities, focuses on basic Ajax operations that deal with forms, form controls, Ajax tables, and upload operations. Some "best" practices based on user experience and the performance of the specific system are explained.

Chapter 3, Useful Tools Using jQuery discusses jQuery plug-ins that are useful in transforming a normal website into an Ajaxified website with good looking tooltips, image galleries with a lighbox, selecting dates with datepicker, quick visual effects, and layout functionality.

Chapter 4, Advanced Utilities, teaches us how to build advanced features like chat, plotting charts, decoding Captcha using canvas, and displaying data in grid..

Chapter 5, Debugging and Troubleshooting, discusses JavaScript debugging techniques using browser plug-ins like Firebug.

Chapter 6, Optimization, teaches us how to speed up code execution through minification, triggering JavaScript early, object caching, and tips from YSlow and Google Page Speed tools.

Chapter 7, Implementing Best Practices to Build Ajax Websites, discusses best practices like avoiding markup-specific codes, building search-engine friendly Ajax websites, security considerations, and implementing Ajax Comet.

Chapter 8, Ajax Mashups, discusses how to make use of existing web services from JavaScript by utilizing Flickr, Picasa, Facebook, Twitter, Google Maps, and geocoding web services.

Chapter 9, iPhone & Ajax, teaches us how to build mobile friendly websites using mobile frameworks and build a native iPhone application using a PhoneGap framework.

What you need for this book

In this book you basically need Apache, MySQL, and PHP installed in your computer. If you don't have PHP, MySQL, or Apache installed in your computer, we would recommend you download the XAMPP package from its website: http://www.apachefriends.org/en/xampp.html. Furthermore, as the code editor you can use a simple editor like Notepad++ (Windows), IDE Netbeans, or Eclipse.

Who this book is for

This book is an ideal resource for people who like to add Ajax features to websites and who prefer standards and best practices for building SEO-friendly websites. As the book covers advanced topics, readers need to be aware of basic PHP, JavaScript, and XML features.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

if(isset($_GET["param"])){
$result["status"] = "OK";
$result["message"] = "Input is valid!";
} else {
$result["status"] = "ERROR";
$result["message"] = "Input IS NOT valid!";
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

" $('#dob').datepicker({
"   numberOfMonths: 2
" });

Any command-line input or output is written as follows:

# cp /usr/src/asterisk-addons/configs/cdr_mysql.conf.sample
     /etc/asterisk/cdr_mysql.conf

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.