我已经在这个网站上阅读了很多,但是我无法解决我的问题! :( 它必须是很容易的,但它不工作!XMLHttpRequest responseText为空
问题是http.responseText
是空的。
网络空间是不是更多钞票,以获得与一个String的www.google.de
源代码?
感谢您的帮助!
<html>
<title>Test Site</title>
<body>
<h1>My Example</h1>
<script type="text/javascript">
var http = new XMLHttpRequest();
http.open("GET", 'https://www.google.de', true);
http.send(null);
http.onreadystatechange = function() {
alert(http.responseText);
}
alert("The end is reached");
</script>
<b>Here is some more HTML</b>
</body>
</html>
你不能用ajax下载其他人的东西,除非他们打开CORS来允许它。 – dandavis
同源政策; https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript –
如果您尝试向不同的域发出请求,请求返回为空(“Access-Control-Allow-Origin”) –