Created
October 31, 2012 21:04
-
-
Save varnit/3989842 to your computer and use it in GitHub Desktop.
yui3 xdr with credentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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