Cross-Domain Ajax/XHR for Embedded Javascript Widgets
I’ve been looking for a solution to the problem of cross-domain XHR restrictions. Cross domain Ajax/HXR is necessary for creating a communications channel to and from embedded javascript widgets. The problem is simple: widgets embedded in a user’s site (blog, etc.) cannot instantiate Ajax/XHR requests because they do not reside on the same domain as the host serving the widget. This is an incredible bummer since it drastically limits what’s possible from an embedded javascript widget.
That’s where flXHR comes in:
flXHR [flĕkʹsər],(flex-er) is a client-based cross-browser, XHR-compatible tool for cross-domain Ajax (Flash) communication. It utilizes an invisible flXHR.swf instance that acts as sort of a client-side proxy for requests, combined with a Javascript object/module wrapper that exposes an identical interface to the native XMLHttpRequest (XHR) browser object, with a few helpful additions and a couple of minor limitations.
It’s an incredibly clever use for flash. (Apparently the concept has been around for a while.) I’ve used flash as a middle-man before with SWFUpload, but I’ve never thought to use it as a client-side proxy for cross-domain XHR. There’s also a jQuery plugin that allows you to replace jQuery’s standard ajax transport with a flXHR version. There are of course, some downsides, but in the end, it bridges the gap to richer widget interactions with minimal fuss.
Find This Article Useful?
Related Articles
About this entry
You’re currently reading “Cross-Domain Ajax/XHR for Embedded Javascript Widgets,” an entry on MirthLab
- Published:
- Wednesday, June 3rd, 2009 at 3:54 pm
- Author:
- Mark Quezada
- Category:
- Links, Web Development

2 Comments
Jump to comment form | comments rss | trackback uri