Wednesday, March 9, 2005

AJAX and Rails

rails_logo_remix_small.gif I posted previously about communicating with Rails using XMLHttpRequest, or AJAX, as it’s starting to be called. Since that post, Rail 0.10 (and 0.10.1!) were released with the new Routes functionality.

Anyway, I’ve created a couple of JavaScript classes to aid in using the XMLHttpRequest stuff. I’ve been using them on a little project I’ve been working on (and will soon announce) and they are working great on Safari, Firefox, and Windows IE 6! I updated them for use with Routing and, being the nice guy that I am, I thought I’d share them with the world.

I call them Connectors. They connect the browser to the (Rails) server via JavaScript and XMLHttp. There are two classes, both in the same .js file: RailsConnector, and JsonConnector. They can be used Synchronously or Asynchronously.

In the aforementioned blog post, I talk a bit about the API — but the source is actually fairly well commented. It even has a couple of usage examples. So what are you waiting for? Download it!

connectors.js(8 KB)

You can use this script however you like. So have a look at it, kick the tires. I only ask that if you find any bugs, make any fixes, let me know!

3 comments:

  1. Ajax and Rails: more of a good thing
    M@ McCray � AJAX and Rails Anyone working with Ruby right now? a couple of JavaScript classes to aid in using the XMLHttpRequest stuff. I�ve been using them on a little project I�ve...

    ReplyDelete
  2. Do u have any undergraduation level project running on AJAX

    ReplyDelete
  3. hi,
    i'm new to this Ajax and Rails thing, but got very interested about it when i started researching on such technologies. Can anyone please tell me what Ajax and Rails is? What is it all about and how companies use it?
    Thank you

    ReplyDelete