Useful use of AJAX

My previous use of AJAX (see earlier posts or check with google) was to load articles in the 404i FWDX site. There was no real need for it per se, just a an excuse to test the technology. However, this week I need to build a javascript powered quick support response system. By that I mean, clicking a button and “Dear Dr. XYZ” is inserted in the text box of the support response form. Another button appends the “Yours sincerely…” bit. However, the big chunk of text depends on the nature of the response, but there’s a series of standard letters that could be dropped in.

Now it implement this I realised that it would make sense to have the various replies kept in a database table. Then I figured on the server I would use ASP to build a large string (“||”) delimited into a client-side run javascript function that would convert the huge string into an array and then select the correct element of this array. This strategy starts to look flawed once you have more than 3 standard letter sitting end to end on a single string.

Then, in a blinding flash it occured to me I just needed to pull the correct text item directly out of the database using AJAX, straight into the text box. Works a treat.

The moral of the story is: keep your eyes open to new technologies as they come along – they can make a difficult job a lot simpler, giving you more time to play with your sodoku (I did my first and last of one of these this week too – went back to my hand-held chess computer for good, honest misery).

Advertisements

About this entry