SOS

Shane O'Sullivan's technical blog… really ties the room together

Cross domain Ajax requests in Dojo…. and there was much rejoicing

Posted by Shane O'Sullivan on August 1, 2006

This is going to be huge! Dojo now supports cross domain Ajax requests, something that has been out of the reach of most Web 2.0 programmers until now. It’s implemented using Iframes, which has both pros and cons (get more info here) but against the couple of issues people might have with it are the two facts:

  • It works! It might use more memory, or it may be slower than normal, but dammit, it works! If you want to keep on using server side proxies or Flash, that’s fine, but here is a standalone, client-side solution that works.
  • It’s ridiculously simple to use. As with all other remote requests in Dojo, the mighty dojo.io.bind function is used, this time with a single new parameter. As the documentations states, you do:

dojo.require(“dojo.io.*”);
dojo.require(“dojo.io.XhrIframeProxy”);

dojo.io.bind({
iframeProxyUrl: “http://some.domain.com/path/to/xip_server.html”,
url: “http:/some.domain.com/path/to/api”,
load: function(type, data, evt, kwArgs){
/* do stuff with the result here */
}
});

and it all just works. The emboldened parts are the only client-side changes that have to made to existing code. There needs to be server side support too of course, but that is the case with all Ajax sites, so it’s hardly something to criticise.

Final verdict is that this is one of the most important additions to Dojo (after the namespace support of course *ahem*) in quite some time.

Now, as for the security/morality of doing remote Ajax calls….. after all, browsers block it for a reason. Very nasty things can be done if you can access any remote content you like from a Javascript enabled client. However, it seems that this code can only go against remote endpoints that support this Dojo feature, so there should hopefully be no problem there either. Seems like this one’s a keeper folks.

7 Responses to “Cross domain Ajax requests in Dojo…. and there was much rejoicing”

  1. Wow: Microsoft Photosynth

    A friend of mine just sent me this article about a piece of software coming out of Microsoft…

  2. I just couldn’t depart your site prior to suggesting that I really loved the standard info an individual provide
    for your visitors? Is going to be again continuously in order to check out new posts

  3. Its not my first time to visit this web site, i am visiting this web site dailly and get nice data from here
    daily.

  4. Woah! I’m really digging the template/theme of this website.

    It’s simple, yet effective. A lot of times it’s challenging to get
    that “perfect balance” between superb usability and visual appearance.
    I must say that you’ve done a fantastic job with this.
    In addition, the blog loads extremely fast for me
    on Internet explorer. Superb Blog!

  5. Hey very cool blog!! Man .. Beautiful .. Wonderful ..
    I will bookmark your web site and take the feeds also?
    I’m happy to find so many helpful info right here within the post,
    we want work out more techniques in this regard, thank you for sharing.
    . . . . .

  6. Octavia said

    Most definitely, there’s a lots of handy blog posts in this web blog!

  7. Sadie said

    great post I’m a big jackpot fan from Berlin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: