Skip to content

Instantly share code, notes, and snippets.

@josephj
Created December 26, 2011 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephj/1521452 to your computer and use it in GitHub Desktop.
Save josephj/1521452 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="created" content="2011-12-08">
<title>Y.io XDR using Flash</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.4.1/build/cssreset/reset-min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/3.4.1/build/cssfonts/fonts-min.css">
<link rel="stylesheet" href="/prototype.css">
<script src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
<script>
var origin = location.hostname,
target = (origin === "josephj.com" ? "www.josephj.com" : "josephj.com");
</script>
</head>
<body>
<h1>Y.io XDR using Flash</h1>
<p style="text-align:center;">You are in "<script>document.write(origin);</script>"</p>
<div style="text-align:center;">
<button>Get cookie from "<script>document.write(target);</script>"</button>
</div>
<script>
YUI().use("io", function (Y) {
var button = Y.one("button"),
cfg = null,
isReady = false;
// Use flash technique to make cross-domain request.
Y.io.transport({
"src": "/lab/2011/yui3-io-xdr/io.swf",
"id" : "flash"
});
// io:xdrReady event.
Y.on("io:xdrReady", function (e) {
cfg = {
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
xdr: {
use: "flash",
credentials: true
},
timeout: 10000,
on: {
// Fix an YUI 3.2.0 bug.
"success": null
}
};
isReady = true;
});
button.on("click", function (e) {
if (!isReady) {
alert("SWF File has not loaded.\nPlease try it later.");
return;
}
Y.io("http://" + target + "/lab/2011/cors-cookie/demo.php", cfg);
});
// io:success event.
Y.on("io:success", function (id, o, args) {
alert(o.responseText);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment