Ajax: beware of crap

Posted on Tue 01 November 2005
I just found an article on java.net titled " Sprinkle Some AJAX Magic in Your Struts Web Application". Cool, I thought, let's see how Struts people ajaxify their apps.

I usually don't like criticizing, but this is really too much: this article is a mountain of crap!

Let's go through some examples:
- retrieveURL(): posts a form using an HTTP GET method!
- getFormAsString(): sends back all inputs, without considering unchecked checkboxes and radios, multiple selection lists, inputs of type submit, etc.
- processStateChange(): oh no! It does some manual splitting on "<span>" of request.responseText " for robustness, rather than req.responseXml which is more powerful, but requires that you return valid XHTML or XML"!! Hey, what if you want to have <span> also in what you update??
- etc, etc.

So beware, readers of this article: you won't sprinkle magic, but ready-to-break crap all over your applications.

Ajax is not rocket science, but needs a minimum of understanding on how HTTP, HTML and the DOM work to do things cleanly. If you don't feel at ease enough with these, or don't want to reinvent the wheel, get an Ajax library rather than writing ugly stuff.



Google on the Moon

Artificial Artificial Intelligence