Ajax technology produced online lyrics search function _ajax related

Source: Internet
Author: User
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Untitled Document </title>
<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) {//initialization, specifying handler functions, sending requests
Http_request = false;
Start initializing the XMLHttpRequest object
if (window. XMLHttpRequest) {//mozilla browser
Http_request = new XMLHttpRequest ();
if (http_request.overridemimetype) {//Set 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, failed to create object instance
Window.alert ("Cannot create XMLHttpRequest object instance.");
return false;
}
Http_request.onreadystatechange = ProcessRequest;
Determine how and when the request is sent and whether the next code is executed synchronously
Http_request.open ("Get", url, True);
Http_request.send (NULL);
}
Functions that process return information
function ProcessRequest () {
if (http_request.readystate = = 4) {//Judge object state
if (Http_request.status = = 200) {//information has been successfully returned to start processing information
alert (Http_request.responsetext);
document.getElementById ("Result"). InnerHTML = Http_request.responsetext;
} else {//page is not normal
Alert ("The page you are requesting has an exception.) ");
}
}
}
function Dosearch () {
var f = document.form1;
var geci = F.geci.value;
if (geci== "") {
Window.alert ("Please enter the lyrics you want to query");
F.geci.focus ();
return false;
}
else {
document.getElementById ("Result"). Innerhtml= "Being queried, please wait";
Send_request (' http://www.efish.cn/getgeci.aspx?m= ' +escape (GECI));
}
}
function SubmitForm () {
if (window.event.keycode==13) {
Dosearch ();
}
}
</script>
<p></p><p></p>
<form id= "Form1" Name= "Form1" method= "Post" action= "" >
<center><span style= "FONT-SIZE:18PX; Color: #FF0000 "> 100,000 lyrics online free enquiry </span></center>
<p></p>
Please enter a song name:
<input name= "Geci" type= "text" id= "Geci" value= "Dongfeng Broken" size= "" height= "" maxlength= "" "onkeydown=" SubmitForm "/ >
<input type= "button" name= "search" value= "Query lyrics" onclick= "Dosearch ()" ><br
<span id= "Result" ></span>
</form>
</body>

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.