Static to Ajax in Minutes
The script and how-to van be viewed and downloaded here.
Yes, animations. It's only eye-candy, but it improves both the style of your website and the user's impression of your website.
There are two types of animations available in the script. We have the tweens that smoothly fit content into your page, and the alpha transitions which display content with a nice fade in. As if that isn’t enough, these animations are customizable!
There are 13 types of tweens available, from normal easeIn or easeOut tweens to elastic and bouncy. There’s also an option to disable the tweens and alpha transitions. This might be good for large pages, since they demand some CPU usage from the visitor's computer.
You can add more eye-candy in the customizable loading-messages, for example, a nice loading image in gif-format or even little flash-movies. By adding CSS-styles in the loading-messages this can be very easy.
It's a bit more than your average, “Hey-I-can-do-ajax” script. With this script you can add event listeners, set up custom rules and custom animations, manage the filetypes handled by the script, and so on.
Attaching event listeners to certain events launched by the script allows you to execute certain pieces of code whenever an event happens, for example, on errors or page loads. Attaching an event listener is very easy. You can attach an event with one line of code. Just like in actionscript, we can use the “addEventListener” function with the same two parameters, the event and the function to execute.
Custom rules allow us to tell the script to discard certain links or forms, or even to only notify the server when a user has clicked a certain link or posted a form. These rules can come in handy when you don’t want certain links to be parsed in ajax, for example, feeds or trackbacks. When it's implemented in a Wordpress theme, you’ll need to add these rules for the wp-admin folder, feed and trackback links.
Error handling is often overlooked, but not here. The class is able to discover whenever an error occurred and will fix it, when possible. If it notices that there is no way to fix the error, for example, if one of the requested pages doesn’t have the information it needs, it will shut itself down and serve the page as a normal browser request, without any ajax. The ajax-class will then load again when the new page is fully loaded. If the script is able to fix the error, an error-event containing all information will be raised and an appropriate message will be shown. These messages are also customizable.
Webpages often contain images. That's why I’ve built in some image preloading functions. When the ajax-class receives the new page from the server, it starts looking for images in the content areas that need to be refreshed. As long as it's preloading, a (customizable) message will be shown to the user. When the images are fully loaded or the maximum load time has been reached, the script will display the page. And, as you can guess, the maximum load time can also be specified by the user.