有没有办法为GitHub页面上托管的静态页面启用跨源资源共享(CORS)以允许Javascript中的跨源请求?
例如,我们可以以某种方式指示GH页面添加这些HTTP响应标头:
Access-Control-Allow-Origin:*
Access-Control-Allow-Methods:GET,POST
Access-Control-Max-Age: 1000
Access-Control-Allow-Headers:*
Run Code Online (Sandbox Code Playgroud)
... GitHub Pages不支持客户服务器配置文件,如.htaccess或.conf ...
...听起来不是很有希望 - 或者有办法吗?
我在Github页面上托管了一些JSON文件,但$.getJSON除非它们来自完全相同的域,否则我无法使用它来检索它们.
有没有办法为Github页面启用CORS?
如何让wolfram的api请求工作?我只是得到跨源错误和空白响应:"XMLHttpRequest无法加载http://api.wolframalpha.com/v2/query?input=No&appid=xxx.访问控制不允许使用Origin null(或其他站点) -允许原产地".
代码是
var request = new XMLHttpRequest();
request.open("GET", "http://api.wolframalpha.com/v2/query?input=pi&appid=xxx", true);
request.onreadystatechange = function() {
if(request.readyState == 4) {
console.log("*"+request.responseText+"*");
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢一堆