socialtwister — an archive in time

Question for the AJAX-minded

filed under Crossover

I've spent the last couple of weeks in retreat mode working on the backend for the Sparkcasting system. It's really a long, arduous process but certainly not one I've not walked before.

As I began to implement the system, I've started to implement some AJAX features into the design of the administration (and maybe into the front end as well). AJAX is certainly not new to me, I've been writing JS/DHTML via IFRAME for something like 7 years now and it was quite a bit of fun then too. Of course, now there's a renewed interest in it seeing that the browser technology is better.

Since I've started, I find myself tripping over my own mind in many occassions. I'm not firm on this decision yet, but it seems best to implement the system fully WITHOUT AJAX before moving on to an AJAX-enhanced version. Why? To be lazy. I've got many questions that are arising and would like to get some feedback from others (especially my CF family):

  • Template vs. CFC - AJAX makes use of lots of little validation checks and data retrieval routines. Are you bundling those into methods or fuseaction-like elements, or some hybrid? I'm using a hybrid since I have a public API and need re-use.

  • Data Transport - AJAX provides a number of different ways to get data back to the client. In the past, I've simply generated JS in the IFRAME and called a function in the parent. I tried WDDX the first time out this time, but of course there was a problem. Apparently the WDDX libraries won't work in both Netscape and IE at the same time.

    I'm currently messing with JSON and found this great library for making use of it in CF. Watch out that you will need to also use JSON.parse() to make it resolve properly.

  • Backup Routines - This is by far the most annoying part in my book. It's not all that new to us really, since we had to deal with client-side validation with server-side backup already. What's changing is the nature of the form now. Whereas before we more often "knew" what the form looked like, with AJAX we find ourselves either getting back a much smaller form (in the case no JS was used) or a much larger form (in the case some JS was used).

    I'll admit that my natural tendency is to be exclusionary in this regard. I don't like to think of myself as a bastard, but what the heck ;) I'm leaning towards requring a certain level browser (note I did not say certain browser. In general, this will mean IE5.5+, Firebird/fox, and Safari if it behaves. How is everyone else dealing with the modern browsers?

  • White Space - If you're having problems with your returned data, make sure you check for generated white space. I've tried to remove it all but the hunt is still on.

There's plenty more I could offer, but I'll stop here. As they say, a picture's worth a thousand words so here's a quick screen grab. In this particular shot, I've tried to save the new row (with no data) and the validation routine told me I wasn't too bright ;):

sparkcasting.ajax.1.gif