Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use ajax Technology to make online lyrics search function

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how to use ajax technology to make online lyrics search function". In daily operation, I believe many people have doubts about how to use ajax technology to make online lyrics search function. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions of "how to use ajax technology to make online lyrics search function". Next, please follow the editor to study!

The code is as follows:

Untitled document

Var http_request = false

Function send_request (url) {/ / initialize, specify the handling function, 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) {/ / set 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, failed to create object instance

Window.alert ("cannot create XMLHttpRequest object instance.")

Return false

}

Http_request.onreadystatechange = processRequest

/ / determine how to send the request and URL, and whether to execute the next code synchronously

Http_request.open ("GET", url, true)

Http_request.send (null)

}

/ / functions that handle the returned information

Function processRequest () {

If (http_request.readyState = = 4) {/ / determine the status of the object

If (http_request.status = = 200) {/ / the information has been returned successfully. Start processing the information.

/ / alert (http_request.responseText)

Document.getElementById ("result") [xss_clean] = http_request.responseText

} else {/ / Page is not normal

Alert ("there is an exception in the page you requested.")

}

}

}

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") [xss_clean] = "querying, please wait"

Send_request ('http://www.efish.cn/getgeci.aspx?m='+escape(geci));

}

}

Function submitForm () {

If (window.event.keyCode==13) {

Dosearch ()

}

}

One hundred thousand lyrics can be found online for free.

Please enter the song name:

At this point, the study on "how to use ajax technology to make online lyrics search function" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report