function loadQexoFriends(id, url) { var uri = url + "/pub/friends/"; var loadStyle = '

友链加载中...

'; document.getElementById(id).className = "qexo-friends"; document.getElementById(id).innerHTML = loadStyle; var ajax; try { // Firefox, Opera 8.0+, Safari ajax = new XMLHttpRequest(); } catch (e) { // Internet Explorer try { ajax = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { ajax = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("糟糕,你的浏览器不能上传文件!"); return false; } } } ajax.open("get", uri, true); ajax.setRequestHeader("Content-Type", "text/plain"); ajax.onreadystatechange = function () { if (ajax.readyState == 4) { if (ajax.status == 200) { var res = JSON.parse(ajax.response); if (res["status"]) { var friends = res["data"]; document.getElementById(id).innerHTML = ""; for (let i = 0; i < friends.length; i++) { document.getElementById(id).innerHTML += '

' + friends[i]["name"] + '
' + friends[i]["description"] + '
'; } } else { console.log(res["data"]["msg"]); } } else { console.log("友链获取失败! 网络错误"); } } }; ajax.send(null); }