PHP jQuery Cookbook

PHP jQuery Cookbook
eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $63.98    Print cover: $39.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Create rich and interactive web applications with PHP and jQuery
  • Debug and execute jQuery code on a live site
  • Design interactive forms and menus
  • Another title in the Packt Cookbook range, which will help you get to grips with PHP as well as jQuery

Book Details

Language : English
Paperback : 332 pages [ 235mm x 191mm ]
Release Date : December 2010
ISBN : 1849512744
ISBN 13 : 9781849512749
Author(s) : Vijay Joshi
Topics and Technologies : All Books, Web Development, AJAX, jQuery, Open Source, PHP

Table of Contents

Chapter 1: Handling Events with jQuery
Chapter 2: Combining PHP and jQuery
Chapter 3: Working with XML Documents
Chapter 4: Working with JSON
Chapter 5: Working with Forms
Chapter 6: Adding Visual Effects to Forms
Chapter 7: Creating Cool Navigation Menus
Chapter 8: Data Binding with PHP and jQuery
Chapter 9: Enhancing your Site with PHP and jQuery
Appendix: Firebug
  • Chapter 1: Handling Events with jQuery
    • Introduction
    • Executing functions when page has loaded
    • Binding and unbinding elements
    • Adding events to elements that will be created later
    • Submitting a form with jQuery
    • Checking for missing images
    • Creating the select/unselect all checkboxes functionality
    • Capturing mouse events
    • Creating keyboard shortcuts
    • Displaying user selected text
    • Dragging elements on a page
    • Chapter 2: Combining PHP and jQuery
      • Introduction
      • Fetching data from PHP using jQuery
      • Creating a query string automatically for all form elements
      • Detecting an AJAX request in PHP
      • Sending data to PHP
      • Aborting AJAX requests
      • Creating an empty page and loading it in parts
      • Handling errors in AJAX requests
      • Preventing browser from caching AJAX requests
      • Loading JavaScript on demand to reduce page load time
      • Chapter 3: Working with XML Documents
        • Introduction
        • Loading XML from files and strings using SimpleXML
        • Accessing elements and attributes using SimpleXML
        • Searching elements using XPath
        • Reading an XML using DOM extension
        • Creating an XML using DOM extension
        • Modifying an XML using DOM extension
        • Parsing XML with jQuery
        • Chapter 4: Working with JSON
          • Introduction
          • Creating JSON in PHP
          • Reading JSON in PHP
          • Catching JSON parsing errors
          • Accessing data from a JSON in jQuery
          • Chapter 5: Working with Forms
            • Introduction
            • Adding input fields dynamically in a form
            • Searching for user-inputted string in a page
            • Checking for empty fields using jQuery
            • Validating numbers using jQuery
            • Validating e-mail and website addresses using regular expressions
            • Displaying errors as user types: Performing live validation
            • Strengthening validation: validating again in PHP
            • Creating a voting system
            • Allowing HTML inside text areas and limiting HTML tags that can be used
            • Chapter 6: Adding Visual Effects to Forms
              • Introduction
              • Creating a Tic-Tac-Toe game with effects
              • Informing a user while an AJAX request is in progress
              • Creating expandable and collapsible boxes (accordion)
              • Fading an element after updating it
              • Floating box on demand
              • Updating items in a shopping cart
              • Chapter 7: Creating Cool Navigation Menus
                • Introduction
                • Creating a basic drop-down menu
                • Creating a menu that changes background on mouse-over
                • Creating an accordion style menu
                • Creating a floating menu
                • Creating an interface for tabbed navigation
                • Adding more tabs
                • Creating a wizard using tabs
                • Chapter 8: Data Binding with PHP and jQuery
                  • Introduction
                  • Fetching data from a database and displaying it in a table format
                  • Collecting data from a form and saving to a database
                  • Filling chained combo boxes that depend upon each other
                  • Checking username availability from database
                  • Paginating data for large record sets
                  • Adding auto-suggest functionality to a textbox
                  • Creating a tag cloud
                  • Chapter 9: Enhancing your Site with PHP and jQuery
                    • Introduction
                    • Sending cross-domain requests using server proxy
                    • Making cross-domain requests with jQuery
                    • Creating an endless scrolling page
                    • Creating a jQuery plugin
                    • Displaying RSS feeds with jQuery and PHP
                    • Appendix: Firebug
                      • Introduction
                      • Inspecting elements
                      • Editing HTML and CSS
                      • Debugging JavaScript

                      Vijay Joshi

                      Vijay Joshi is a web developer who lives in New Delhi, India, with his wife and daughter. Coming from a small town named Pithoragarh, Uttarakhand in the Himalayas, he fell in love with coding while in college and then again with PHP and JavaScript/jQuery since his early coding days. He believes that if you are passionate and enjoy your work, it becomes more of a hobby thatis not boring and never feels like a job.

                      After freelancing for a few years, he co-founded a web development firm called Developers Lab along with two of his friends in New Delhi where they build products for the travel industry and create custom web applications.

                      Vijay is also author of PHP jQuery Cookbook, published by Packt, and technical reviewer of PHP AJAX Cookbook and jQuery UI 1.8: The User Interface Library for jQuery.

                      When not coding, he likes to read, spend time with his family, blog occasionally at, and dreams about getting back in shape.

                      Sorry, we don't have any reviews for this title yet.

                      Code Downloads

                      Download the code and support files for this book.

                      Submit Errata

                      Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                      - 2 submitted: last submission 17 Apr 2014

                      Errata Category: Code Related | Chapter 1: Submitting a form with jQuery
                      In the code files "<input type="submit" value="Submit Form" />" should be: "<input type="button" value="Submit Form" />"

                      Support Query | Page No: 23-24

                      The following code is no longer valid at the latest version the closest working code:


                      To fully fix the problem, replace the line:


                      with the following:


                      This is to be done as the .live operator has been removed after jquery 1.7.

                      Sample chapters

                      You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                      Frequently bought together

                      PHP jQuery Cookbook +    Node.js Blueprints =
                      50% Off
                      the second eBook
                      Price for both: $40.05

                      Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                      What you will learn from this book

                      • Start from the basics and learn pro-level tricks by the end of the book
                      • Create interactive and dynamic hierarchical menus
                      • Apply eye-catching effects on form elements
                      • Integrate a database along with PHP and jQuery
                      • Use AJAX to enhance user experience and page interaction
                      • Learn how to work with JSON and XML for efficient data exchange
                      • Create tools and utilities for your web applications
                      • Master form validation on client side as well as server side

                      In Detail

                      As web technology evolves, the gap between desktop applications and web applications continues to vanish. And what better way to bridge that gap, for your own website, than using the best two open source technologies in the market: PHP and jQuery. The power-combo of these two is leading the way in revolutionizing the RIA world. Although they are easy to integrate, finding or figuring out how to do what you want to do is rather arduous.

                      The PHP jQuery Cookbook will be your handy guide with walkthroughs of common integration tasks and problems that will help you master the possibilities available using the PHP and jQuery combo. You will learn quick solutions to necessary tasks to integrate the power of two of the best known and most widely used web technologies of today – PHP on the server side and jQuery on the client side. Glide through the basics and move to advanced topics to create dynamic and interactive web applications with this book in hand.

                      This book covers a wide array of technical aspects of creating an interactive website. Apart from basics of PHP and jQuery, you will go through advanced topics like creating plugins, validating controls, and useful utilities that you will be able to use as stand-alone tools. AJAX, the key technique of browser-server communication is covered in detail. You will also learn to use JSON, which is becoming preferred as a mode of data interchange over XML, both in web applications and web services.

                      The book also covers database interaction, which is an important part of any dynamic web application. You will also gain expertise in debugging JavaScript with the help of useful tools that will save you hours of tedious manual debugging.

                      Most importantly, by using jQuery and PHP together, you will be able to develop applications that are compatible with all major browsers, with no need to write code targeted at specific browsers!

                      A package of comprehensive solutions to problems that may occur while building web applications with PHP and jQuery


                      Written in Packt's cookbook style, this book presents numerous practical examples that you can use directly in your applications. The book covers most of the essential issues you will face while developing your web applications and gives solutions to them. Recipes in the book are written in a manner that will rapidly take you from a beginner to expert level.

                      Who this book is for

                      If you want to use PHP and jQuery together to create web applications this book is for you. It provides a large number of examples in each chapter that will take you from a basic developer to a pro by giving step-by-step instructions for each task in developing web applications using PHP and jQUery. All you need are JavaScript basics and you are on your way to building power web applications, with this book in hand.

                      Code Download and Errata
                      Packt Anytime, Anywhere
                      Register Books
                      Print Upgrades
                      eBook Downloads
                      Video Support
                      Contact Us
                      Awards Voting Nominations Previous Winners
                      Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                      Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software