Skip to content

Instantly share code, notes, and snippets.

@varnit
Created October 31, 2012 21:04
Show Gist options
  • Save varnit/3989842 to your computer and use it in GitHub Desktop.
Save varnit/3989842 to your computer and use it in GitHub Desktop.
yui3 xdr with credentials
YUI({ filter:'raw' }).use('node-event-delegate', 'io-xdr', function (Y) {
var followList = Y.one('#onboard');
followList.delegate('click', function(e) {
e.preventDefault();
var url = this.ancestor('form').getAttribute('action');
console.log(url);
var handleSuccess = function(id, o, a) {
console.log('success');
};
var handleFailure = function(id, o, a) {
console.log('failure');
};
var cfg = {
method: 'GET',
xdr: {
use: "native",
credentials: true
},
headers: {
'Accept': 'application/json'
},
on: {
success: handleSuccess,
failure: handleFailure
}
};
console.log(Y.io(url, cfg));
}, 'button');
});
// make sure your server returns the following headers:
// Access-Control-Allow-Origin: http://yourhostname.com // this should match the 'Origin' header sent by the browser
// Access-Control-Allow-Credentials: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment