javascript - 从外部站点检索数据

标签 javascript

我想从使用 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/

相关文章:

javascript - API 服务限制我或我的巨大 for 循环对于我的 POST 请求来说太快?

javascript - jQuery 替换为正则表达式无法正常工作

javascript - 检查 undefined variable 在 Chrome 中不起作用

javascript - 使 AngularJS Controller 中的 $location 无效

javascript - 使用 TweenLite 从中间到边缘径向淡入图像

javascript计算价格并在我在表单中插入数字后立即查看(输入类型 ='number' )

javascript - 如何更改传递 javascript 变量的 DataTable 的语言

javascript - JSON.stringify 在我的 float 周围加上引号

Javascript:有趣的正则表达式对象名称?

javascript - 2 个 div 彼此相邻