Example 4: Debug Information (and How Does Taconite Work?)
By now you're quite familiar with using Taconite. In a nutshell, all you have to do is create an AjaxRequest object, provide it with the endpoint URL, optionally add any query parameters, and send the request. On the server side, simply write the XHTML that you want to appear on the page, embed it within some simple Taconite-specific XML tags, and send the response back to the browser. Taconite handles the rest.
What if the server isn't sending back the response you think it is? Debugging within the server environment can often be tricky and error-prone. Or, what if the Taconite parser isn't working the way you think it should be? How can you dig into the "guts" of Taconite?
Enabling Debugging Information
The AjaxRequest object provides a method called setEchoDebugInfo(). Calling this method before sending the Ajax request will tell Taconite to write debugging information to the Web page where you can easily see it. That's all you need to do -- Taconite does the rest!
Listed below is the doHelloWorld() function from Example 1. Note that the only change is to call the setEchoDebugInfo() function before calling the send() method:
Try it yourself and see what happens. You'll be able to easily see the result sent by the server, and the results of any parsing that occurred within the browser.
The AjaxRequest object provides the setEchoDebugInfo() method which tells Taconite to write the server's response and the results of any parsing operations to the Web page for easy viewing. This can be used to debug problems and also as a learning tool to understand what Taconite is doing under the covers.