使用 Ajax 获取 QQ 空间头像信息 - 跨域请求解决方案
你可以使用 XMLHttpRequest 来进行 Ajax 请求,然后将请求类型设置为 'document'。以下是一个示例代码:
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://users.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?uins=3338007395');
xhr.responseType = 'document';
xhr.onload = function() {
if (xhr.status === 200) {
var responseText = xhr.responseXML.documentElement.textContent;
// 进行处理
console.log(responseText);
}
};
xhr.send();
注意,由于涉及跨域请求,你需要确保在请求中添加适当的跨域请求头或使用 JSONP 等其他方法来处理跨域问题。
原文地址: https://www.cveoy.top/t/topic/qoFa 著作权归作者所有。请勿转载和采集!