11.3. Microsoft Fiddler

Since the core of Ajax relies on requests going to servers (and responses being received from them), it makes sense that debugging Ajax applications relies heavily on understanding what is being sent to and received from the server. FireBug for Firefox inspects the requests and responses sent through XHR objects, but this is only a very small percentage compared to all of the requests and responses used during a typical user session. And, as discussed in the previous section, many requests may be sent without using XHR at all. The way to solve these problems is to use an HTTP proxy.

An HTTP proxy is a small program running on the client computer that intercepts all HTTP requests and responses. In normal HTTP communication, the browser initiates and sends a request over the Internet to a server. The server then sends a response back to the browser, which then acts upon the data it received. When an HTTP proxy is used, all requests are first sent through the proxy; it's the proxy's job to send that request to the server. The response is sent back to the proxy as well, and the proxy then forwards it to the browser (see Figure 11-3).

However, the true value of the HTTP proxy isn't the simple interception of requests and responses but rather the ability to log the details of this communication. By being able to see the entirety of each request or response, including headers, debugging Ajax communication is made much simpler. This is where Microsoft Fiddler comes ...

Get Professional Ajax, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.