javascript 根据歌名获取播放地址和歌词内容
给大家吧,做在线听歌时,少不了他们的,由于用到了外部的jquery.js文件,所以运行代码后请重新刷新页面生效!
听歌
$(function(){
$("#surl").bind("click",function(){
$("#surl").attr("disabled",true);
var song = encodeURI($("#kw").val());
song = encodeURI(song);
var str = "
- ";
- 待选:"+n+"
$.getJSON("http://www.faqee.com/crm/song?act=songurl&song="+song+"&jsoncallback=?", function(json){
$.each(json,function(i,n){
n = n+"";
i = i+"";
if(i!="res"){
var ss = "
";
str=str+ss;
}else{
if(n == "0"){
alert("抱歉,搜索不到歌曲!");
$("#surl").attr("disabled",false);
return;
}
}
});
str = str+"
";
$("#searchsesult").html(str);
$("#surl").attr("disabled",false);
});
});
$("#slrc").bind("click",function(){
$("#slrc").attr("disabled",true);
var song = encodeURI($("#kw").val());
song = encodeURI(song);
var str = "";
$.getJSON("http://www.faqee.com/crm/song?act=songlrc&song="+song+"&jsoncallback=?", function(json){
$.each(json,function(i,n){
n = n+"";
i = i+"";
if(i!="res"){
$("#searchsesult").html(n);
$("#slrc").attr("disabled",false);
return;
}else{
if(n == "0"){
alert("抱歉,搜索不到歌词!");
$("#slrc").attr("disabled",false);
return;
}
}
});
});
});
});
搜索:[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]