我想从这个URL加载数据:http://gateway.fpts.com.vn/monitor/realtime/?s=aaa使用Javascript。如何从JavaScript中的链接URL获取数据请求?
在我的浏览此网址返回数据,如下图所示:
这里是我试过的代码:
<html>
<head>
<title>The jQuery Example</title>
<script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<div id= "stage"></div>
<script type = "text/javascript" language = "javascript">
var url = "http://gateway.fpts.com.vn/monitor/realtime/?s=aaa"
$.ajax({
url: url,
cache: false,
method: "GET",
})
.done(function(html) {
$("#stage").append(html);
});
</script>
</body>
</html>
但我收到此错误:
XMLHttpRequest cannot load http://gateway.fpts.com.vn/monitor/realtime/?s=aaa&_=1465298988417 . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
阅读关于jQuery.ajax()这里http://api.jquery.com/jquery.ajax/。 – void