Sajax 0.11 pre-release

Tlack, the man behind the curtain for Sajax, put out a new version last week for testing purposes.

There are a few new features and other assorted announcements to go with it, but the one that caught my eye was the ability to return arbitrary variable types (in PHP): arrays, objects, ints, floats, and strings. I haven’t worked with that yet, but theres been at least a few times I’ve wanted to do exactly that.

And the original forum post is here: Sajax 0.11-pre announcement

Or for the exceedingly lazy, here’s the original post:

Hi guys, and long time no see!

I’ve been a little busy with a massive new project and haven’t had much time to devote to Sajax. Luckily I have had some time this week and a new Sajax — version 0.11 — is almost available. Two major changes and three little ones:

1. I’ve added support for setting a “target id”, to which output from the remote script will be sent. In other words, Sajax now does the document.getElementById(id).innerHTML = whatever; step for you. Though this isn’t a huge change, I think it will be pretty helpful in writing smaller, simpler code. To do this, set sajax_target_id = “myid”; and do your calls as usual. (You can set the variable to blank to turn off this behavior)

2. The PHP backend now encodes returned results as JavaScript types, which are interpreted with eval(). It supports arrays, objects (only the variables are exported), ints, floats and, of course, strings. I settled on the eval() method because it made it easier to express diverse, nested types without tons of client-side work.

3. I have made some small cleanups to the source.

4. I have added two new ‘examples’, which I will probably later rename tests: one of them tests returning complex objects, the other tests mixing GET, POST and target-id requests.

5. The wall example is now improved to not flicker and to adaptively set the refresh frequency. (If new data was found, it checks again in one second; if not, it checks again 2.5 seconds. I avoided implementing a full TCP/IP back-off algorithm.. Wink)

I’m releasing a test candidate here:
and I would love everyone’s feedback.

Oh, and one more thing: a blog we are hosting migrated to WordPress and the system load on our server has been pegged at 0.5 – 1.5 all day ever since. We’re hoping to find a way to improve this soon. In the meantime, please bare with the slow speed of

2 Responses to Sajax 0.11 pre-release
  1. Kevin Pratt
    April 28, 2005 | 2:43 am

    No, your right this capability has existed for some time now. But for whatever reason (it was complicated, they were lazy, poor browser support, the cookies were just coming out of the oven, who knows) not many people were using it like this; or at least not doing really neat things with it where lots of people would see it and like it. But then along comes gmail and gmaps (and their attendent Oooh, Shiny!!!+14) factor. And this, at least partially, starts people thinking ‘Hey, thats neat. How did they do that?’ and more importantly, ‘How can I do that?’

    As for sajax…. Its true, none of this stuff is anything that any programmer worth his salt couldn’t figure out, but all the XMLHTTPReq finagling can be a bit convoluted (or at least seem that way–especially to someone not intimately familiar with js and the dom, like me for example, who is coming from a c++, and later php, background). And sajax, as the name implies, just makes this all very simple to implement. And as with most languages, when a library exists for some function, it usually makes a good bit of sense to at least start there, and customize later if the need arises.

    That at least is my somewhat cursory take on what this is all about…… But as some of the earlier articles on the blog indicate, many older and wiser souls have already weighed in on this issue, so if you’re looking for an answer, you might peruse some of those articles.

  2. justin
    April 26, 2005 | 4:10 am

    i really dont see the point of Sajax. Nearly 2 years ago , I used a combination of Javascript and DOM objects to make an interactive PHP calender app, without any refreshing needed , and this was waay before all of this ajax buzz.

    all ajax is , is just another buzzword for using Javascript – i really still dont see what all the fuss is about.