Cross-domain Ajax requests

With Flash or Without Flash ? flXHR or jXHR ?

flXHR (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.

The result is that flXHR can be used as a drop-in replacement for XHR based Ajax, giving you consistent, secure, efficient cross-domain client-to-server cross-domain Ajax communication, without messy workarounds such as IFRAME proxies, dynamic script tags, or server-side proxying.

http://flxhr.flensed.com

jXHR is less than 1.3k minimized (and ~690 bytes gzip'd), and has no dependencies.

jXHR is a clone-variant of the XMLHttpRequest object API, meaning it is (for the most part) API compatible. Some properties are not supported, such as responseText/XML/Body, and the request/response header functions are no-op's. Also, only "GET" is supported for the 'method' parameter of open(). And jXHR currently ignores any 'data' value passed to the send() function. All data you wish to send must be manually serialized into the 'url' parameter of open().

jXHR makes cross-domain JSON-P styled calls. The URL you pass to open() should have a parameter (usually named "callback") whose value is "?". The ? placeholder will be replaced by an internal callback created by jXHR. However, you can have the JSON-P data passed to your own callback handler by defining one for the "onreadystatechange" property of your jXHR instance.

http://test.getify.com/jXHR

© 2010 Devis Lucato.