6

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?

Felix
  • 88,392
  • 43
  • 149
  • 167

3 Answers3

5

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

geowa4
  • 40,390
  • 17
  • 88
  • 107
  • 1
    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 Oct 04 '09 at 01:03
4

Have a look at http://snook.ca/archives/javascript/cross_domain_aj/

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.

  • 1
    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 – Felix Sep 30 '09 at 19:49
  • 1
    so how does this answer html5 ajax to another domain? this merely shows the workarounds of old, before html5. – geowa4 Sep 30 '09 at 19:54
1

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

Pacerier
  • 86,231
  • 106
  • 366
  • 634