Note: The following statement does not support cross-origin ajax, and does not support cross-origin of subdomains.
/*
* <Div id = "show_info"> </div>
* <Input type = "button" id = "requestButton" value = "Send a POST Request">
*/
YUI (). use ("io", function (Y ){
Var show_info = Y. one ('# show_info ');
Var handleSuccess = function (ioId, o ){
If (o. responseText! = Undefined ){
Var s = "<li> Transaction id:" + ioId + "</li> ";
S + = "<li> HTTP status:" + o. status + "</li> ";
S + = "<li> Status code message:" + o. statusText + "</li> ";
S + = "<li> HTTP headers received ed: <ul>" + o. getAllResponseHeaders () + "</ul> </li> ";
S + = "<li> page response:" + o. responseText + "</li> ";
Show_info.set ("innerHTML", s );
}
}
Var handleFailure = function (ioId, o ){
If (o. responseText! = Undefined ){
Show_info.set ("innerHTML", "handleFailure ");
}
}
Y. on ('IO: success ', handleSuccess );
Y. on ('IO: failure ', handleFailure );
Var cfg = {
Method: "POST ",
Data: "user = fengyue & password = 888 ",
// Data :""
};
Var sUrl = "http://www.alimama.net: 8080/union/aa.htm ";
Function makeRequest (){
Show_info.set ("innerHTML", "Loading data from new request ...");
Var request = Y. io (sUrl, cfg );
}
Y. on ("click", makeRequest, "# requestButton ");
});