O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

AJAX and PHP: Building Modern Web Applications - Second Edition

Book Description

Key Features

  • The ultimate AJAX tutorial for building modern Web 2.0 Applications
  • Create faster, lighter, better web applications by using the AJAX technologies to their full potential
  • Leverage the power of PHP and MySQL to create powerful back-end functionality and make it work in harmony with a responsive AJAX clientWrite better JavaScript code to enable powerful web features
  • Understand the complete client-server mechanism by following complete, step-by-step case studies

Book Description

AJAX enables interactive interfaces that can replace traditional user interfaces. Enhance the user experience of your PHP website using AJAX with this practical and friendly tutorial! This book is the most efficient resource you can get to enter the exciting world of AJAX with PHP. Based on numerous examples and detailed case studies, this AJAX with PHP tutorial will build your foundation knowledge for creating faster, better web applications.

The best AJAX tutorial for PHP developers has been completely rewritten to be your friendly guide to modern Web 2.0 development techniques! AJAX and PHP: Building Modern Web Applications, 2nd Edition covers every significant aspect of creating and maintaining AJAX and PHP applications.

What you will learn

  • Create faster, lighter, better web applications by using the AJAX technologies to their full potential
  • Learn to use PHP and MySQL on the server, and Javascript and jQuery on the client, to build real-world AJAX applications
  • Combine client-side and server-side functionality to enhance the user experience of your site using AJAX
  • Learn to simulate private, instance, and static class members in JavaScript
  • Build an AJAX-enabled form validation page, which is safe to work even if the client doesn't support JavaScript and AJAX

Who this book is for

AJAX and PHP: Building Modern Web Applications, 2nd Edition, 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 be able to assess the security and SEO implications of their code

Downloading the example code for this book. 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 code file.

Table of Contents

  1. AJAX and PHP
    1. Table of Contents
    2. AJAX and PHP
    3. Credits
    4. About the Authors
    5. About the Reviewer
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Errata
        2. Piracy
        3. Questions
    7. 1. The World of AJAX and PHP
      1. The big picture
        1. AJAX and Web 2.0
      2. Building websites since 1990
        1. HTTP and HTML
        2. PHP and other server-side technologies
        3. JavaScript and other client-side technologies
        4. What's missing?
      3. The world of AJAX
        1. What is AJAX made of?
        2. Uses and misuses of AJAX
        3. Resources and tools
      4. Setting up your environment
      5. Building a simple application with AJAX and PHP
        1. Time for action – Quickstart AJAX
          1. What just happened?
      6. Summary
    8. 2. JavaScript and the AJAX Client
      1. JavaScript and the Document Object Model
        1. Time for action – playing with JavaScript and the DOM
          1. What just happened?
      2. JavaScript events and the DOM
        1. Time for action – using JavaScript events and the DOM
          1. What just happened?
      3. Even more DOM
        1. Time for action – even more DOM
          1. What just happened?
      4. JavaScript, DOM, and CSS
        1. Time for action – working with CSS and JavaScript
          1. What just happened?
      5. Using the XMLHttpRequest object
        1. Creating the XMLHttpRequest object
          1. JavaScript exception handling
          2. Creating better objects for Internet Explorer 6
        2. Initiating server requests using XMLHttpRequest
        3. Handling server response
          1. Time for action – making asynchronous calls with XMLHttpRequest
            1. What just happened?
      6. Working with XML structures
        1. Time for action – making asynchronous calls with XMLHttpRequest and XML
          1. What just happened?
        2. Handling more errors and throwing exceptions
        3. Creating XML structures
      7. Summary
    9. 3. Object Oriented JavaScript
      1. Why is OOP in JavaScript important?
      2. Object-oriented programming concepts
        1. Encapsulation
        2. Inheritance
        3. Polymorphism
      3. Object-oriented programming with JavaScript
        1. JavaScript objects are dictionaries
        2. JavaScript functions
          1. JavaScript functions are first-class objects
          2. Inner functions
          3. Closures
        3. JavaScript classes
          1. Constructors
          2. Class diagrams
          3. Referencing external functions
          4. Prototype objects
          5. Instance methods and properties
          6. Static methods and properties
          7. Private members
        4. The JavaScript execution context
          1. var x, this.x, and x
          2. Using the right context
      4. JavaScript OOP in practice: Introducing JSON
        1. JSON concepts
        2. A simple JSON example
          1. Time for action – using JSON
      5. Summary
    10. 4. Using PHP and MySQL on the Server
      1. PHP, DOM, and XML
        1. Time for action – server-side AJAX with PHP and XML
          1. What just happened?
      2. PHP and JSON
        1. Time for action – server-side AJAX with PHP and JSON
          1. What just happened?
      3. Passing parameters and handling PHP errors
        1. Time for action – passing PHP parameters and error handling
          1. What just happened?
            1. divide.php
            2. error_handler.php
            3. handleServerResponse()
      4. Working with MySQL
        1. Creating database tables
        2. Manipulating data
        3. Connecting to your database and executing queries
          1. Time for action – working with PHP and MySQL
            1. What just happened?
      5. Summary
    11. 5. AJAX Form Validation
      1. Implementing AJAX form validation
      2. XMLHttpRequest, version 2
        1. Time for action – the XmlHttp object
          1. What just happened?
      3. AJAX form validation
        1. Time for action – AJAX form validation
          1. What just happened?
      4. Summary
    12. 6. Debugging and Profiling AJAX Applications
      1. Debugging and profiling with Internet Explorer
        1. Enabling debugging in Internet Explorer 6 and 7
        2. Debugging in Internet Explorer 8
        3. Other Internet Explorer debugging tools
      2. Debugging and profiling with Firefox
        1. Firebug
        2. Venkman JavaScript debugger
        3. Web Developer
      3. Summary
    13. 7. Advanced Patterns and Techniques
      1. Predictive fetching pattern
      2. Progress indicator pattern
      3. Unobtrusive JavaScript
      4. Progressive enhancement and graceful degradation
      5. Asynchronous file upload with AJAX
        1. HTTP and how file upload works
        2. Iframe for asynchronous file upload with AJAX
          1. Time for action – asynchronous file upload with AJAX
            1. What just happened?
      6. Cross-domain calls
        1. Cross-domain calls using a server proxy
        2. Cross-domain calls using Flash
        3. Cross-domain calls using iframes
        4. Cross-domain calls using JSONP
      7. Cross-site request forgery
        1. JSON hijacking
        2. Mitigations of CSRF
      8. Cross-site scripting
        1. Exploits
          1. Non-persistent XSS
          2. Persistent XSS
        2. Mitigations of XSS
          1. Input validation
          2. Escaping
          3. Cookies security
      9. Summary
    14. 8. AJAX Chat with jQuery
      1. Chatting using AJAX
      2. jQuery
        1. Before we get started
        2. The first steps
          1. jQuery DOM Selectors
          2. jQuery wrapper object
        3. Method chaining
        4. Event handling
        5. A simple example
        6. Basic concepts
      3. AJAX chat
        1. The chat application
          1. Time for action – implementing AJAX chat with JSON
            1. What just happened?
            2. How does the color picker work?
      4. Summary
    15. 9. AJAX Grid
      1. Implementing the AJAX data grid
        1. Code overview
          1. The database
          2. Styles and colors
          3. The server side
          4. Creating the grid, step by step
      2. Summary
    16. A. Preparing Your Working Environment
      1. Installing XAMPP
        1. Installing XAMPP on Windows
        2. Installing XAMPP on Linux
      2. Preparing the AJAX database
    17. Index