参考:
代码:
| function getUrlRespHtml_async(url, callback){   var xmlHttp = new XMLHttpRequest();   xmlHttp.onreadystatechange = function() {     if (xmlHttp.readyState == ReadyState.DONE && xmlHttp.status == 200)       callback(xmlHttp.responseText);   }   xmlHttp.open("GET", url, true);   xmlHttp.send(null); } function gotStHtml(respHtml){   // alert(respHtml);   console.log(respHtml); } /*   Loving You Allexinno Mirabela 试听 — SongTaste 用音乐倾听彼此   http://www.songtaste.com/song/3498546/ */ var stUrl = "http://www.songtaste.com/song/3498546/"; // var stUrl = "http://www.baidu.com"; getUrlRespHtml_async(stUrl, gotStHtml); | 
转载请注明:在路上 » 【已解决】js中如何写函数