<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<title>Ajax</title>
<script type= "Text/javascript" language= "JavaScript"
Src= "Prototype.js" ></script>
<script type= "Text/javascript" language= "JavaScript" >
function Test () {
var myajax = new Ajax.request (
' Http://www.wanfangdata.com.cn ',
{
Method: ' Get ',
Oncomplete:showresponse
}
);
}
function Showresponse (response) {
$ (' Divresult '). InnerHTML = Response.responsetext;
}
var handle = {
Oncreate:function () {
Element.show (' loading ');
},
Oncomplete:function () {
if (Ajax.activerequestcount = = 0) {
Element.hide (' loading ');
}
}
};
Ajax.Responders.register (handle)//register handle to the global ajax.responders,ajax.responders to maintain a list of running Ajax objects
</script>
<body>
<input type= "button" value= "click" onclick= "Test ()"/>
<div id= "Divresult" ></div>
<div id= ' loading ' style= ' Display:none ' >
loading
</div>
</body>