tags:

views:

846

answers:

3

I recently came across http://chromeexperiments.com/. I found a couple of projects there that are quite intriguing: 100 Tweets and twitterbrowse (I'd post links to them but I'm not yet allowed). These both work fine for me in Firefox 3.5 under Ubuntu 9.04. The thing that I find particularly peculiar is the fact that these two "experiments" seem to issue Ajax requests to other domains than the ones they are hosted on (to twitter.com, more exactly). I have tried the same thing on an HTML5 page (using <!DOCTYPE html>), but I can't get it to work.

I'm using MooTools to create the requests, but that shouldn't be a problem, it's still Ajax, right?

Any idea how those sites are doing this?

A: 

Have a look at http://snook.ca/archives/javascript/cross%5Fdomain%5Faj/

I personnaly was able to do this using the JSON method on a personal project where I had to receive ajax response from a different domain's server.

Indeed. I looked through jQuery's source and realized it checks if the request is made to another domain and in that case it dynamically creates a <script> tag and loads it in that.
Felix
so how does this answer html5 ajax to another domain? this merely shows the workarounds of old, before html5.
geowa4
+1  A: 

XMLHttpRequest Level 2 allows for cross-domain AJAX. Read more about it here.

geowa4
Thank you for the link, very interesting. Unfortunately, that document does not specify in which conditions a cross-domain request can be issued. I also doubt that XMLHttpRequest L2 has been implemented so far in any browser.
Felix
A: 

They aren't using HTML5 for the ajax request, they're using JSONP which is essentially a getter for JSON, but can be made across any domain

mistergoomba