If it won't be simple, it simply won't be. [Hire me, source code] by Miki Tebeka, CEO, 353Solutions

Thursday, July 24, 2008

CGI trampoline for cross site AJAX

Most (all?) browsers won't let you do cross site AJAX calls.

One solution is JSONP (which is supported by jQuery). However not all servers support it.

The other solution is to create a "trampoline" in your site that returns the data from the remote site:

2 comments:

Gregory Benison said...

And you'll get even better performance if you write the trampoline in C.

This is a really useful technique and I'm kind of surprised it isn't used more often. For example it can be used to implement complex redirection behavior on hosts where you don't have total control over the server configuration.

Miki Tebeka said...

I doubt how much speedup you'll get from writing this in C since most of the time is spent on I/O.

If you want to speed things up without much effort, consider using Cython.

Blog Archive