i have just spent 2 weeks coding my first ajax application and it was like sticking needles incessantly into my eyes. argh, the agony. the last time i had this much trouble coming to grips with a programming practice was when i was learning how to program CGI applications in Perl. that was something like 8 years ago, but AJAX brought back all the memories of those frustrating times.
why is AJAX difficult to learn? first you have to come to grips with the javascript methods of performing remote HTTP calls AFTER the browser page has loaded. you can use the javascript Prototype library to help you with this. this isn't so bad, but the whole point of using AJAX is that you perform (presuming that you are doing anything interesting) multiple asynchronous operations that can each go wrong, and you have to somehow monitor the success/failure of each of the operations and react accordingly. one little keystroke in the wrong place and your javascript fails silently and you are left looking at a page that seems to be thinking about doing something but just grins at you stupidly while doing nothing.
then there is the rethinking of how to process CGI data, because very strange things can happen if you don't process data in the right order. i spent half a day trying to figure out why my application refused to read data from my database. it turned out that having form data sitting on the line somehow blocked the database read operations. that was just one of the subtlties i came across.
having said all that, the end result is application functionality that just happens to be vital to my software and there is no other way of implementing it that i know of. but still, the blood, the sweat, the tears. i feel like i just went through that Sun Vow initiation that Richard Harris endured in "The Man Called Horse"
