Friday, October 23, 2009

Chapter 5. Ajax Using HTML and JavaScript











Chapter 5. Ajax Using HTML and JavaScript




Human beings, as well as other life forms, are made up of chemicals such as iron, nitrogen, and water. However, simply mixing everything together in a cauldron and giving it a quick stir won't result in someone climbing out of the cauldron. The reason for this is that it isn't the type of ingredients put together; it is how the ingredients are put together. After all, if girls really were made of sugar and spice and everything nice, there would be a lot more geeky guys with dates at the prom. If you've ever read Lester Del Rey's short story Helen O'Loy, you might be accustomed to the concept of building a date from things lying about.


The same is true for web applications. Consider for a moment what is commonly referred to as Dynamic HTML, or DHTML, for short. Still commonly used in web applications, it is distinguished from plain HTML only by the fact that things happened based upon events. This is where the dynamic part comes in. I would like to point out that at no time did I mention the word JavaScript. The reason for this is that not only is it possible to have DHTML without JavaScript, but it is also possible to have JavaScript without DHTML.


Just in case you're curious, the way to have DHTML without JavaScript is to use Cascading Style Sheets in event handlers instead of JavaScript. Although it wouldn't be quite as flexible as JavaScript, and it could be used only for things such as mouseovers and mouseouts, it does fulfill the dynamic requirement. After all, it really is how the various parts are put together, not the parts themselves. Let's dig a little into the pile of client-side parts available when starting an Ajax application and see what can be of use in building our monster.


In this chapter, however, I intend to take advantage of the tools available to us. Most of these tools are used in the traditional manner. However, some are not; what fun would it be if everything was done according to the manual? Consider frames, for example. Whether or not you're aware of it, you can abuse frames in quite a number of ways. Other tools that I use are the cross-browser Document Object Model and HTML tables for displaying information. Hey, torture the information enough, and eventually it will confess.


In addition to these tools, I cover the ultimate database "tool," stored procedures, but with a quirky difference. The difference is that I'm using MySQL, not Oracle or Microsoft SQL Server. Just in case you're wondering why, I have three very good reasons. The first is that MySQL is an open source database. The second is that stored procedures are rather new in MySQL, so there isn't very much written about them. The final reason, and, in my opinion the most important, is that my wife keeps me on a budget; alas, no Tesla coils for me.















No comments: