我浏览了这个问题的答案,但还没有找到一个好的答案。
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);上面是我的javascript代码。我确实使用了http://而不是file://,,并且我确实将文件放在了XAMPP服务器上。正如有人提到的那样,我在save.php中也使用了header('Access-Control-Allow-Origin:*'),但仍然收到相同的错误。
请帮帮忙。
发布于 2014-07-11 07:50:14
我终于明白了。当他们说使用http打开文件时,他们指的是两件事。
在chrome中手动打开该文件
愚蠢的错误..。
https://stackoverflow.com/questions/24687553
复制相似问题