Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PHP jQuery Cookbook

You're reading from   PHP jQuery Cookbook jQuery and PHP are the dynamic duo that will allow you to build powerful web applications. This Cookbook is the easy way in with over 60 recipes covering everything from the basics to creating plugins and integrating databases.

Arrow left icon
Product type Paperback
Published in Dec 2010
Publisher Packt
ISBN-13 9781849512749
Length 332 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Vijay Joshi Vijay Joshi
Author Profile Icon Vijay Joshi
Vijay Joshi
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

PHP jQuery Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Handling Events with jQuery FREE CHAPTER 2. Combining PHP and jQuery 3. Working with XML Documents 4. Working with JSON 5. Working with Forms 6. Adding Visual Effects to Forms 7. Creating Cool Navigation Menus 8. Data Binding with PHP and jQuery 9. Enhancing your Site with PHP and jQuery Firebug Index

Debugging JavaScript


Firebug can also be used to debug JavaScript in a browser. You can place breakpoints and debug the code line by line. In addition to it you can also watch variables and DOM elements changing in real time.

How to do it...

  1. To put breakpoints in your JavaScript code, open Firebug either by clicking the icon in the status bar or by pressing F12.

  2. Then click on the Script button in the Firebug toolbar. This will show a list of all the available scripts for that page.

  3. Select a script among these and that file will be displayed in the Firebug content panel.

  4. After a file has been selected you can put breakpoints on a line by clicking just before the line number. A breakpoint is indicated by a dark brown colour circle.

  5. Now you are ready for debugging. In the example seen in the next screenshot—the tic-tac-toe game—place a breakpoint on line 18. It will execute whenever a column of the game is clicked upon.

  6. Click on a column and you will see that the execution has halted on that line.

  7. Now you can watch the code execution line by line. To go to the next line press F10 on your keyboard. If you encounter a function, you can press F11 and control step into it.

  8. You can also watch variables. In the right panel there is a line called New Watch Expression. You can write a variable name or an expression here and Firebug will evaluate its value.

  9. Pressing F8 will continue the code execution till another breakpoint is encountered.

There's more...

Debugging in a nutshell

  • F8: Continue.

  • F10: Step Over. It takes control to next line.

  • F11: Step Into. If you press F11 on a line where a function is defined, control will go inside the defined function.

  • F12: Open or close Firebug on a web page.

Inspecting AJAX requests

The console of Firebug logs all the AJAX requests sent from the browser. It also shows the response code for each request. For each request, the parameters sent, request and response headers, and server response can be seen.

Web developer toolbar

The Web developer toolbar is another handy tool, through which you can control behaviour of various elements on the page. It also provides a large set of tools that operate on web pages.

You can disable or enable JavaScript, images, view page structure, form info, and so on. It can be obtained from https://addons.mozilla.org/firefox/addon/60.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image