[英]Origin null is not allowed by Access-Control-Allow-Origin.
I browse the answer for this question, but haven't find a good answer for me yet. 我浏览了该问题的答案,但尚未找到适合我的好答案。
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(request.readyState == 4 && request.status == 200){
var response = response.responseText;
window.open(response, "_blank", "location = 0, menubar = 0");
}
}
request.open("POST", "http://localhost/save.php", true)
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send("imag="+data);
the above is my javascript code. 以上是我的JavaScript代码。 I did use http:// instead of file://, and I did put the files on XAMPP server. 我确实使用http://而不是file://,并且确实将文件放在XAMPP服务器上。 I also use header('Access-Control-Allow-Origin: *') in my save.php as someone mentioned, but I still get the same error. 我也提到过在save.php中使用header('Access-Control-Allow-Origin:*'),但仍然出现相同的错误。
Some help please... 请帮忙...
I finally get it. 我终于明白了。 When they say using http to open the file, they mean 2 things. 当他们说使用http打开文件时,它们表示两件事。
Silly mistakes... 愚蠢的错误...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.