Created
December 26, 2011 15:40
-
-
Save josephj/1521452 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!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