Ajax technology makes online lyrics search function

Source: Internet
Author: User

Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
</Head>
<Body>
<Style type = "text/css">
<! --
Body {
Background-color: # FFFFFF;
Font-size: 85%;
Font-family: Verdana;
Margin-top: 10px;
Margin-left: 10px;
}
A: link {color: #3737c8}
A: active {color: # f00 ;}
A: visited {color: #639 ;}
-->
</Style>
<Script language = "javascript">
Var http_request = false;
Function send_request (url) {// initialize, specify the processing function, and send the request function
Http_request = false;
// Start initializing the XMLHttpRequest object
If (window. XMLHttpRequest) {// Mozilla Browser
Http_request = new XMLHttpRequest ();
If (http_request.overrideMimeType) {// sets the MiME category
Http_request.overrideMimeType ('text/xml ');
}
}
Else if (window. ActiveXObject) {// IE browser
Try {
Http_request = new ActiveXObject ("Msxml2.XMLHTTP ");
} Catch (e ){
Try {
Http_request = new ActiveXObject ("Microsoft. XMLHTTP ");
} Catch (e ){}
}
}
If (! Http_request) {// exception. An error occurred while creating the object instance.
Window. alert ("the XMLHttpRequest object instance cannot be created .");
Return false;
}
Http_request.onreadystatechange = processRequest;
// Determine the request sending method and URL and whether to execute the following code synchronously
Http_request.open ("GET", url, true );
Http_request.send (null );
}
// Function for processing the returned information
Function processRequest (){
If (http_request.readyState = 4) {// judge the object status
If (http_request.status = 200) {// The information has been returned successfully. Start to process the information.
// Alert (http_request.responseText );
Document. getElementById ("result"). innerHTML = http_request.responseText;
} Else {// The page is abnormal.
Alert ("the page you requested has an exception. ");
}
}
}
Function dosearch (){
Var f = document. form1;
Var geci = f. geci. value;
If (geci = ""){
Window. alert ("Enter the lyrics you want to query ");
F. geci. focus ();
Return false;
}
Else {
Document. getElementById ("result"). innerHTML = "querying... please wait ";
Send_request ('HTTP: // www.efish.cn/getgeci.aspx? M = '+ escape (geci ));
}
}
Function submitForm (){
If (window. event. keyCode = 13 ){
Dosearch ();
}
}
</Script>
<P> </p>
<Form id = "form1" name = "form1" method = "post" action = "">
<Center> <span style = "font-size: 18px; color: # FF0000"> 100,000 online free query of lyrics </span> </center>
<P> </p>
Enter the song name:
<Input name = "geci" type = "text" id = "geci" value = "Dongfeng broken" size = "60" height = "30" maxlength = "50" onKeyDown =" submitForm () "/>
<Input type = "button" name = "search" value = "query lyrics" onClick = "dosearch ()"> <br/>
<Span id = "result"> </span>
</Form>
</Body>
</Html>

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.