我想从使用 js 函数加载的外部站点获取一些值。到目前为止,我已经尝试过类似的方法,但我确信这不是正确的方法
window.location = "http://dashboard.monitis.com/sharedPage.jsp?tI=OHIHg3S9XiBj70SNtIGi0g%253D%253D&uI=hGCXtzJFZF0M2GGYsvfYunNBx3EZykTidEFveqU24IY%253D";
x = document.getElementsByClassName('x-grid3-cell-inner x-grid3-col-1')[0].textContent;
alert(x);
最佳答案
window.location 会将您的浏览器重定向到该位置,因此脚本的其余部分永远不会执行。您可能想使用 ajax 请求获取该 url 的内容,然后对该内容执行某些操作。
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
}
};
xhttp.open("GET", "http://dashboard.monitis.com/sharedPage.jsp?bla..bla", true);
xhttp.send();
关于javascript - 从外部站点检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39330027/