upgraded yui to 2.2.2 and yui-ext to 1.0.1a
This commit is contained in:
parent
4d9af2c691
commit
547ced6500
1992 changed files with 645731 additions and 0 deletions
120
www/extras/yui/examples/connection/get.html
Normal file
120
www/extras/yui/examples/connection/get.html
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src = "../../build/yahoo/yahoo-min.js" ></script>
|
||||
<script src = "../../build/connection/connection-min.js" ></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../docs/assets/dpSyntaxHighlighter.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1> Connection Manager GET Transaction</h1>
|
||||
<p>
|
||||
To construct a GET transaction using the Connection Manager, you will need to construct a querystring of key-value pairs and append it to the URL.
|
||||
The following code example provides a step-by-step approach to creating a simple GET transaction.
|
||||
</p>
|
||||
|
||||
<h3>Source file and dependencies</h3>
|
||||
<p>Load the YAHOO namespace and connection manager source file:</p>
|
||||
|
||||
<pre><textarea name="code" class="JScript" cols="60" rows="1"><script src="yahoo.js"></script>
|
||||
<script src="connection.js"></script></textarea></pre>
|
||||
|
||||
<h3>Assemble the Querystring</h3>
|
||||
<p>Construct a querystring with two key-value pairs of <em>username = anonymous</em> and <em>userid = 0</em>:</p>
|
||||
|
||||
<pre><textarea name="code" class="JScript" cols="60" rows="1"> /*
|
||||
*
|
||||
* Create a querystring with example key-value pairs of
|
||||
* username and userid. Remember to encode the querystring
|
||||
* if and when the string contains special characters.
|
||||
*
|
||||
*/
|
||||
var sUrl = "php/get.php?username=anonymous&userid=0";</textarea></pre>
|
||||
|
||||
<h3>The Callback Object</h3>
|
||||
<p>Create a callback object to handle the response, and pass an object literal to both success and failure as the argument.</p>
|
||||
<pre><textarea name="code" class="JScript" cols="60" rows="1">
|
||||
var div = document.getElementById('container');
|
||||
|
||||
var handleSuccess = function(o){
|
||||
if(o.responseText !== undefined){
|
||||
div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
|
||||
div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
|
||||
div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
|
||||
div.innerHTML += "<li>HTTP headers: <ul>" + o.getAllResponseHeaders + "</ul></li>";
|
||||
div.innerHTML += "<li>Server response: " + o.responseText + "</li>";
|
||||
div.innerHTML += "<li>Argument object: Object ( [foo] => " + o.argument.foo +
|
||||
" [bar] => " + o.argument.bar +" )</li>";
|
||||
}
|
||||
}
|
||||
|
||||
var handleFailure = function(o){
|
||||
if(o.responseText !== undefined){
|
||||
div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
|
||||
div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
|
||||
div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
|
||||
}
|
||||
}
|
||||
|
||||
var callback =
|
||||
{
|
||||
success:handleSuccess,
|
||||
failure: handleFailure
|
||||
argument: { foo:"foo", bar:"bar" }
|
||||
};</textarea></pre>
|
||||
|
||||
<h3>Initiate the GET Transaction</h3>
|
||||
<p>Call YAHOO.util.Connect.asyncRequest to send the request to get.php,
|
||||
and the PHP file will return the output of $_POST via <strong>print_r()</strong>.
|
||||
The handleSuccess callback will print the response object's properties, including
|
||||
the server response data.
|
||||
</p>
|
||||
<p>
|
||||
Note: Caching and GET idempotency.
|
||||
</p>
|
||||
|
||||
<pre><textarea name="code" class="JScript" cols="60" rows="1">var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);</textarea></pre>
|
||||
|
||||
<div id="container"></div>
|
||||
<script>
|
||||
var div = document.getElementById('container');
|
||||
|
||||
var handleSuccess = function(o){
|
||||
if(o.responseText !== undefined){
|
||||
div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
|
||||
div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
|
||||
div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
|
||||
div.innerHTML += "<li>HTTP headers: <ul>" + o.getAllResponseHeaders + "</ul></li>";
|
||||
div.innerHTML += "<li>Server response: " + o.responseText + "</li>";
|
||||
div.innerHTML += "<li>Argument object: Object ( [foo] => " + o.argument.foo +
|
||||
" [bar] => " + o.argument.bar +" )</li>";
|
||||
}
|
||||
}
|
||||
|
||||
var handleFailure = function(o){
|
||||
if(o.responseText !== undefined){
|
||||
div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
|
||||
div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
|
||||
div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
|
||||
}
|
||||
}
|
||||
|
||||
var callback =
|
||||
{
|
||||
success:handleSuccess,
|
||||
failure:handleFailure,
|
||||
argument: { foo:"foo", bar:"bar" }
|
||||
};
|
||||
|
||||
var sUrl = "php/get.php?username=anonymous&userid=0";
|
||||
|
||||
function makeRequest(){
|
||||
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
|
||||
}
|
||||
</script>
|
||||
<form><input type="button" value="Send a GET Request" onClick="makeRequest();"></form>
|
||||
|
||||
<script src="../../examples/assets/dpSyntaxHighlighter.js"></script>
|
||||
<script language="javascript">
|
||||
dp.SyntaxHighlighter.HighlightAll('code');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue