Home
easyXDM is a Javascript library that enables you as a developer to easily work around the limitation set in place by the Same Origin Policy.
Why don’t you start with seeing it for your self? Run the test suite, or try the RPC demo.
Features
- A bi-directional, reliable, secure and queueable Socket class that can transport strings between domains using the best transport available
- Easy to use RPC class, that enables you to expose and call methods across the domain boundary
- Supports <15ms transits in IE6+, Opera 9+, Firefox 1+, Safari 4+ and Chrome 2+ with no dependencies (only include easyXDM.js)
- Supports slower fallback transports like window.name and FIM for all other browsers
- Has no server-side dependencies (proxies etc.)
- Readable and minified production code, and a special debug version with extensive tracing capabilities
- A ready to use endpoint for exposing ajax calls
- Easy to use with regular authentication
Goals for the project
- be easy to use
- be secure
- be fast
- be self contained, no dependencies (not counting JSON)
- be light weight (4.5Kb gzipped)
- be flexible
- have excellent code quality
- have excellent documentation
- be the best xdm-library in existence
The library provides two layers of abstraction that simplifies development and usage.
easyXDM.Socket gives access to a simple string based transport stack which can be used to send strings between two documents in different domains. The underlying transport stacks does not have any dependencies outside the script itself and what the browser offers.
The transport stacks all offer reliability, queuing and sender-verification.
easyXDM.Rpc lets you call methods with arguments and return values across the domain boundary. It uses JSON-RPC and is also able to relay request to a custom backend (for instance the server using ajax). Since both ends are free to use AJAX the Rpc class can be used to easily expose AJAX in a cross-domain fashion.
Example
This is the code needed to expose a method using RPC
var rpc = new easyXDM.Rpc({}, {
local: {
post: {
post: function(url, data, fn, fnError){
easyXDM.ajax({
src: url,
type: "json",
data: data,
success: fn,
error: fnError
});
}
}
}
});
And consuming it isn’t much more
var xhr = new easyXDM.Rpc({
remote: remoteUrl + "/../xhr.html"
}, {
remote: {
post: {}
}
});
xhr.post("example/glossary.php", {
param1: "foo",
param2: bar"";
}, function(json){
alert(json.glossary.title);
});
Instant cross-domain AJAX!
