ajax技術(shù)制作得在線歌詞搜索功能
更新時間:2006年09月23日 00:00:00 作者:
復(fù)制代碼 代碼如下:
<!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>無標(biāo)題文檔</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) {//初始化、指定處理函數(shù)、發(fā)送請求的函數(shù)
http_request = false;
//開始初始化XMLHttpRequest對象
if(window.XMLHttpRequest) { //Mozilla 瀏覽器
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {//設(shè)置MiME類別
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) { // IE瀏覽器
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) { // 異常,創(chuàng)建對象實例失敗
window.alert("不能創(chuàng)建XMLHttpRequest對象實例.");
return false;
}
http_request.onreadystatechange = processRequest;
// 確定發(fā)送請求的方式和URL以及是否同步執(zhí)行下段代碼
http_request.open("GET", url, true);
http_request.send(null);
}
// 處理返回信息的函數(shù)
function processRequest() {
if (http_request.readyState == 4) { // 判斷對象狀態(tài)
if (http_request.status == 200) { // 信息已經(jīng)成功返回,開始處理信息
//alert(http_request.responseText);
document.getElementById("result").innerHTML = http_request.responseText;
} else { //頁面不正常
alert("您所請求的頁面有異常。");
}
}
}
function dosearch() {
var f = document.form1;
var geci = f.geci.value;
if(geci=="") {
window.alert("請輸入你要查詢的歌詞");
f.geci.focus();
return false;
}
else {
document.getElementById("result").innerHTML="正在查詢,請稍候";
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">十萬歌詞在線免費查詢</span></center>
<p></p>
請輸入歌曲名:
<input name="geci" type="text" id="geci" value="東風(fēng)破" size="60" height="30" maxlength="50" onKeyDown="submitForm()" />
<input type="button" name="search" value="查詢歌詞" onClick="dosearch()"><br />
<span id="result"></span>
</form>
</body>
</html>
相關(guān)文章
Ajax調(diào)用restful接口傳送Json格式數(shù)據(jù)的方法
這篇文章主要介紹了Ajax調(diào)用restful接口傳送Json格式數(shù)據(jù)的方法的相關(guān)資料,非常不錯,具有參考借鑒價值,感興趣的朋友一起看下吧2016-07-07asp.net中mvc使用ajax提交參數(shù)的匹配問題解決探討
本文為大家介紹下使用javaScript解決asp.net中mvc使用ajax提交參數(shù)的匹配問題,遇到類似情況的朋友可以參考下,希望對大家有所幫助2013-07-07Ajax獲取到數(shù)據(jù)放入echarts里不顯示的原因分析及解決辦法
在做一個需要用到echarts地圖的項目的時候,成功通過ajax獲取到了后臺提供的數(shù)據(jù),并生成了想要的JSON串。但是,放到echarts option.series[0].data里,獲取不到數(shù)據(jù)。在生成的地圖上無法看到你從后臺獲取到的值,下面小編給大家分享我的解決辦法,需要的朋友參考下2016-01-01ajax.js里面有內(nèi)容顯示效果,根據(jù)ID
ajax.js里面有內(nèi)容顯示效果,根據(jù)ID...2006-10-10