Learning a little AJAX
Today was spent experimenting with something I’ve intended to for a long time: PHP and AJAX. I finally bit the bullet and started learning it in earnest. 
This morning was spent searching for a suitable PHP toolkit to tinker with. The one I finally arrived at is the SAJAX toolkit, a moderately minimal framework for creating simple callbacks and recievers without having to go through the nitty-gritty of the lower-level XMLHttpRequest APIs. After playing around with it for a while, I really like it. There are some things that are quite confusing to me as a first time user, such as the asynchronous nature of things and the effects on variable scope - but all in all it’s quite a nice system to play with.
I also discovered a quite wonderful little Firefox extension called FireBug. It has to be the most clean and cleverly put together all-purpose debugger I’ve ever seen. It’s very beautifully designed, too. It looks to be extremely useful in debugging javascript, css, and xhtml source in the future. It sure helped me out debugging XMLHttpRequests today!
This afternoon was spent scratching my head at things I mostly don’t understand. I figured as a first test project, I would make a little turn-based story creator… just a simple form where users could input a word to add to a continuing story, where the story would be updated in real-time. Hacking pre-existing examples was fine and dandy, though of course it turned out that this was not as simple as I had thought. 
The hardest part to implement was my decision to only allow one word to be added per-person in a row. Storing a persistent session identifier - across the asynchronous submissions - turned out to be a nightmare in persistent variable storage. Try as I might, I could not get global variables to work the way I wanted them to. In the end, I resorted to a file hack out of frustration. Perhaps this is truly the way you are supposed to do it? I suppose I’ll only know by learning and doing more.
My little experiment finally worked, and is quite usable: it runs, though it’s quite boring with nobody else to play with. It’s also quite boring looking. However, it really is a shared workspace, and could probably be bit of fun with a few friends. I’m sure similar games have been done before, but it just occurred to me to be a fun project to do. Hopefully it won’t become a spam hole too quickly.
Next in the queue, I’d like to create some way of displaying how many people are viewing the space currently - to bring the aspect of presence much further into the foreground. After all, as one teacher once said to me: you’re not just writing for yourself: you’re writing for your readers!
About: I am a digital artist and computer geek with interests in Linux, open source design programs, and saving the world. You will find me blogging here about art, life, technology, and other mildly amusing things.
RSS 2.0
