<HTML>
<Script language = "JavaScript" type = "text/JavaScript">
Function ajaxrequest (){
VaR xmlobj = false;
VaR cbfunc, objself;
Objself = this;
Try {xmlobj = new XMLHttpRequest ;}
Catch (e ){
Try {xmlobj = new activexobject ("msxml2.xmlhttp ");}
Catch (E2 ){
Try {xmlobj = new activexobject ("Microsoft. XMLHTTP ");}
Catch (E3) {xmlobj = false ;}
}
}
If (! Xmlobj) return false;
This. method = "Post ";
This. url;
This. async = true;
This. content = "";
This. Callback = function (cbobj) {return ;}
This. Send = function (){
If (! This. Method |! This. url |! This. async) return false;
Xmlobj. Open (this. method, this. url, this. async );
If (this. Method = "Post") xmlobj. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded ");
Xmlobj. onreadystatechange = function (){
If (xmlobj. readystate = 4 ){
If (xmlobj. Status = 200 ){
Objself. Callback (xmlobj );
}
}
}
If (this. Method = "Post") xmlobj. Send (this. content );
Else xmlobj. Send (null );
}
}
Function Google ()
{
VaR v = new ajaxrequest ();
VaR ajaxobj = new ajaxrequest; // create an Ajax object
Ajaxobj. method = "get"; // set the request method to get
Ajaxobj. url = "http://www.google.cn/search? Q = "+ document. getelementbyid (" cc "). Value // The URL is default. asp.
// Set the callback function to output the response content
Ajaxobj. Callback = function (xmlobj ){
// Document. Write (xmlobj. responsetext );
If (xmlobj. readystate = 4)
{
If (xmlobj. Status = 200)
{
Document. getelementbyid ('content'). innerhtml = xmlobj. responsetext;
}
}
}
Ajaxobj. Send (); // send the request
}
</SCRIPT>
<Body>
<Input id = "cc"/> <input type = "button" value = "Search for Google" name = "B3" onclick = "Google ()"/>
<Div id = "content"/>
</Form>
</Body>
</Html>
The Ajax part uses site: http://www.xujiwei.cn/