Fixes cross-domain REST model.load() in older browsers via a simple (optional) config update #1304

wants to merge 1 commit into


None yet

4 participants


Using ModelSync.REST with IE 8 and 9 was failing when loading with cross-domain GET requests (i.e. the URL of the source data is in a separate domain from the current browser window). Unlike with, there is currently no way to pass an XDR config to the underlying AJAX request to fix these errors.

This change simply allows a user to include an XDR object in the "options" parameter of model.load, which is passed through to the underlying call. So the documentation for that option applies (i.e. { use: 'native' }).

In IE 8 and 9, this enables the use of the XDomainRequest which supports XDR; additionally this eliminates the extra preflight OPTIONS request in modern CORS-compliant browsers since setting the XDR config object causes to remove the "X-Requested-With" header.

Chris Hut Enable optional XDR config to be passed into
This update fixes cross-domain ModelSync.REST load()'s on IE 8 and 9, and
(per the code in disables the harmless-but-superfluous preflight OPTIONS
request for XDR requests in modern browsers.
@chrisrhut chrisrhut commented on the diff Oct 11, 2013
@@ -437,7 +437,9 @@ RESTSync.prototype = {
@param {Number} [options.timeout] The number of milliseconds before the
request will timeout and be aborted. This overrides the default provided
by the static `HTTP_TIMEOUT` property.
- @param {Function} [callback] Called when the sync operation finishes.
+ @param {Object} [options.xdr] XDR config object to pass through to
chrisrhut Oct 11, 2013

To be honest this documentation is the part I'm most unsure about, since the documentation on the "xdr" config param is in a state of flux. The current docs imply that the option is deprecated: I know that SWF's are gone from YUI (precluding {use:'flash'}), but I believe native XDR (i.e. using XDomainRequest in IE 8/9) will remain supported?

In either case I believe just positioning this as "pass through to" option will be clear enough to users who need this functionality.

lsmith commented Dec 9, 2013

LGTM, but I think @ericf should weigh in.

@clarle clarle was assigned Dec 9, 2013
@clarle clarle was unassigned by jlecomte Mar 13, 2015

CLA is valid!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment