简体   繁体   English

从外部站点检索数据

[英]Retrieving data from an external site

I would like to get some values from an external site that is loaded using js functions. 我想从使用js函数加载的外部站点获取一些值。 Until now i have tried something like i this but im sure is not the correct way 直到现在,我已经尝试过类似的方法,但是我确定这不是正确的方法

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 will redirect your browser to that location, so the rest of your script is never executed. window.location会将您的浏览器重定向到该位置,因此脚本的其余部分将永远不会执行。 You probably want to fetch the contents of that url using an ajax request and then do something with that content. 您可能想使用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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM