鉴于大家对Ajax十分关注,我们编辑小组在此为大家搜集整理了“Baidu Musicbox 用到的ajax代码”一文,供大家参考学习!
var names;
var Cs, St;
var rorw="";
var lrcT;
function getname(songname){
if(songname==""){
names=$("name").value;
}else{
names=songname;
}
geturl();
}
function geturl(){
AJAXCALL("inc/songurl.asp?type=url1&keyword="+names,"musiclist","isXML=true");
addbox(names);
}
function top(){
AJAXCALL("inc/songlist.asp?ac=new","toplist","isXML=true");
}
function toplist(doc){
var items=getElementsByClass(doc,"item");
var linker=new Array();
var linkers=new Array();
var tmp="<ul>";
for(var i=0;i<items.length;i++){
if(getTagValue(items[i], "singer")=="")
{
linker[i]="";
linkers[i]="";
}
else
{
linker[i]="("+getTagValue(items[i], ''singer'').replace(/ /g," ")+")";
linkers[i]=" "+getTagValue(items[i], ''singer'').replace(/ /g," ");
}
var d=i+1;
tmp+=''<li>''+d+''. <a href=javascript:getname("''+getTagValue(items[i], ''songname'').replace(/ /g," ")+linkers[i]+''") title="''+getTagValue(items[i], ''songname'').replace(/ /g," ")+linker[i]+''">''+getTagValue(items[i], ''songname'').replace(/ /g," ")+linker[i]+''</a></li>'';
}
tmp+="</ul>";
$("toplist").innerHTML=tmp;
}
function s2(){
AJAXCALL("inc/songlist.asp?ac=all","s3"