我正在尝试创建一个可以下载并通过启动其索引文件在本地运行的网站.
所有文件都是本地的,没有资源在线使用.
当我尝试使用jQuery的AJAXSLT插件来处理带有XSL模板的XML文件时(在子目录中),我收到以下错误:
XMLHttpRequest cannot load file:///C:/path/to/XSL%20Website/data/home.xml. Origin null is not allowed by Access-Control-Allow-Origin.
XMLHttpRequest cannot load file:///C:/path/to/XSL%20Website/assets/xsl/main.xsl. Origin null is not allowed by Access-Control-Allow-Origin.
发出请求的索引文件是file:///C:/path/to/XSL%20Website/index.html在存储使用的JavaScript文件时file:///C:/path/to/XSL%20Website/assets/js/.
我该怎么做才能解决这个问题?
我目前正在使用SoundCloud API,并希望在单击按钮时嵌入轨道.
我收到两个错误:
XMLHttpRequest无法加载http://soundcloud.com/oembed.json?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F48419073.Access-Control-Allow-Origin不允许使用null.
和
未捕获的TypeError:无法读取null的属性'html'
这是我的代码:
<button onclick="getPopular()">+1</button>
<div id="track"></div>
<script src="http://connect.soundcloud.com/sdk.js" type="text/JavaScript"></script>
<script type="text/JavaScript">
SC.initialize({
client_id: "**************",
});
var getPopular = function() {
SC.get("/tracks", {limit: 1}, function(tracks) {
var track = tracks[0];
alert("Latest track: " + track.title);
SC.oEmbed(track.uri, document.getElementById("track"));
});
};
</script>
Run Code Online (Sandbox Code Playgroud)
我在代码中使用警报让我知道它实际上是从SoundCloud API获取信息.我只是不确定还有什么阻止它嵌入.
提前谢谢,或者看看我的问题.