Today is a good day to code

I Finally Found a Real-World Use For AJAX

Posted: December 31st, 1969 | Author: | Filed under: JavaScript, Programming, Uncategorized | Tags: , , | No Comments »

I Finally Found a Real-World Use For AJAX

Picture of Irv Owens Web DeveloperI'm working on this project now that makes heavy use of standard javascript, Flash, ColdFusion, and HTML. The project is using the TCallFrame javascript function to control the flash movie. Because of the nature of the project, the timing between the movie refresh calls makes using a refreshing iFrame not possible for the text information that I need to display. Likewise, the text needs to be displayed using complicated styles and colors, controlled by ColdFusion components that Flash can't handle easily.

So I was faced with a dilemma. I couldn't refresh an iFrame without throwing the timing of the TCallFrame request, combined with some javascript cookie writing, I didn't write the original application, and Flash remoting calls. Basically, nothing should happen until the cookie is written, which it doesn't, most of the time.

It eventually dawned on me, not only that the application needed to be strengthened with some type of cookie listener at the very least, and a small-scale rewrite at the most, but that I only really needed the application to think that there was no iFrame refresh, but an AJAX call using an invisible iFrame could work.

So I began working on it and it evolved into a two-part system. On one hand, the div that contained the text to be returned from the ColdFusion components needed to be continuously refreshed, which I found out after struggling with another timing issue. Eventually I realized that the variable that needed to be set in my parent window was empty at the time of the screen refresh because the iFrame hadn't finished loading yet.

So what I had to have happen was for the iFrame to make a javascript function call to the parent once the variable was written. Once I had that accomplished it was easy to have the checkboxes that called the TCallFrame javascript call the function to refresh the iFrame. It worked wonderfully, but unfortunately it still caused a timing issue with the main movie. It delayed the writing of the cookie by a hair. Still it was cool to see, that I had an actual use for AJAX.

I have actually found other uses for it, but none as clear cut as that. Flash just wasn't flexible enough. I'm not reversing myself, I still think that Flash should be most developers' first choice when it comes to remoting, but in a pinch AJAX is allright!