xhr.html revision 1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749
286N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
286N/A<html>
286N/A<head>
286N/A <meta http-equiv="content-type" content="text/html; charset=utf-8">
286N/A<title>Connection Manager GET Transaction</title>
286N/A
286N/A<style type="text/css">
286N/A/*margin and padding on body element
286N/A can introduce errors in determining
286N/A element position and are not recommended;
286N/A we turn them off as a foundation for YUI
286N/A CSS treatments. */
286N/Abody {
286N/A margin:0;
286N/A padding:0;
286N/A}
286N/A</style>
286N/A
286N/A<script type="text/javascript" src="/build/yui.js"></script>
286N/A<script type="text/javascript" src="/build3x/dump/dump.js"></script>
286N/A<script type="text/javascript" src="/build3x/io/io.js"></script>
286N/A
286N/A<!--begin custom header content for this example-->
286N/A<style>
286N/A#container li {margin-left:2em;}
286N/A</style>
286N/A
286N/A
286N/A<!--end custom header content for this example-->
286N/A
286N/A</head>
286N/A
286N/A<body class=" yui-skin-sam">
286N/A
286N/A<h1>Connection Manager GET Transaction</h1>
286N/A
286N/A<div class="exampleIntro">
286N/A <p>To create a GET transaction using <a href="http://developer.yahoo.com/yui/connection/">Connection Manager</a>, you will need to construct a querystring of key-value pairs and append it to the URL.
286N/AThe following code example provides a step-by-step approach to creating a simple GET transaction.</p>
286N/A
286N/A<p>Click "Send a GET Request" below to try it out, then read the description below to learn how to create a simple transaction using Connection Manager.</p>
286N/A</div>
286N/A
286N/A<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->
286N/A
286N/A<div id="container"></div>
286N/A
286N/A<script>
286N/A
286N/Avar Y = YUI().use('dump', 'io');
286N/Avar div = Y.get('#container');
286N/A
286N/Avar handleSuccess = function(id, o){
286N/A
286N/A Y.log("The success handler was called. tId: " + Y.Lang.dump(Y.Array(arguments)) + ".", "info", "example");
286N/A
286N/A if(o.responseText !== undefined){
286N/A div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
286N/A div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
286N/A div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
286N/A div.innerHTML += "<li>HTTP headers: <ul>" + o.getAllResponseHeaders + "</ul></li>";
286N/A div.innerHTML += "<li>Server response: " + o.responseText + "</li>";
286N/A // div.innerHTML += "<li>Argument object: Object ( [foo] => " + o.argument.foo +
286N/A // " [bar] => " + o.argument.bar +" )</li>";
286N/A }
286N/A}
286N/A
286N/Avar handleFailure = function(id, o){
286N/A
286N/A Y.log("The failure handler was called. tId: " + o.tId + ".", "info", "example");
286N/A
286N/A if(o.responseText !== undefined){
286N/A div.innerHTML = "<ul><li>Transaction id: " + o.tId + "</li>";
286N/A div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
286N/A div.innerHTML += "<li>Status code message: " + o.statusText + "</li></ul>";
286N/A }
286N/A}
286N/A
286N/Avar callback =
286N/A{
286N/A on: {
286N/A success:handleSuccess,
286N/A failure:handleFailure
286N/A },
286N/A argument: { foo:"foo", bar:"bar" }
286N/A};
286N/A
286N/Avar sUrl = "assets/get.php?username=anonymous&userid=0";
286N/A
286N/Afunction makeRequest(){
286N/A var request = Y.io(sUrl, callback, 'asd');
286N/A Y.log("Initiating request; tId: " + Y.Lang.dump(request) + ".", "info", "example");
286N/A
286N/A}
286N/A
286N/AY.on('io:success', function() {
286N/A Y.log('global: ' + Y.Lang.dump(Y.Array(arguments)));
286N/A});;
286N/A
286N/AY.log("As you interact with this example, relevant steps in the process will be logged here.", "info", "example");
286N/A
286N/A</script>
286N/A<form><input type="button" value="Send a GET Request" onClick="makeRequest();"></form>
286N/A
286N/A<!--END SOURCE CODE FOR EXAMPLE =============================== -->
286N/A
286N/A</body>
286N/A</html>
286N/A