Micha Schopman wrote:

> " Yup, it's basically an ad-hoc version of RPC. Or at least that's how
> people will inevitably end up using it. I find the whole fuss people are
> making about it just a little much myself."
> 
> That is definitely not Ajax. Ajax is much more than simple remote
> procedure calls.

No, it is. I didn't say that it was just RPC (which is hardly simple), I 
said that's how people would end up using it.

Here's what AJAX boils down to: using XMLHttpRequest to pull data from
the server. How this will probably end up being (ab)used to do is to
implement some kind of ad-hoc RPC mechanism by abusing HTTP's GET verb.

Christ, I've been doing stuff like this for years (albeit *not* abusing
GET), the only difference being that it's been returning JavaScript to
execute rather than a block of raw data. And all my requests were
naturally asynchronous. Heck, here's the code I use too:

function JSRequest(responder)
{
     return function(args)
     {
         var parent = document.getElementsByTagName("body")[0];

         // Remove any existing request block, if possible.
         try
         {
             var old  = document.getElementById("jsreqScript");
             if (old)
                 parent.removeChild(old);
         }
         catch (ex) { /* Ignore */ }

         // Build the call string, appending on any arguments.
         var call = responder;
         for (var name in args)
             call += (call.indexOf("?") == -1 ? "?" : "&") +
                 escape(name) + "=" escape(args[name]);

         // Build the new script element and put it in the head. The
         // script is automatically fetched and ran.
         var script   = document.createElement("script");
         script.id    = "jsreqScript";
         script.src   = call;
         script.type  = "text/javascript";
         script.defer = true;
         parent.appendChild(script);
     }
}

To use it, I just do something like this:

var GetUserDetails =
     JSRequest("http://example.com/remote/getUserDetails.cfm";);
GetUserDetails({id: 5});

And I can do everything with that that you can do with AJAX. And I do
mean *everything* because, at least with the IE implementation, you 
can't use POST, which means no complex data, and all the calls need to
be idempotent. As I said, AJAX isn't interesting, not in the slightest.

K.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:199542
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to