完整的报错是:
from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, edge, https, chrome-untrusted.
翻译是:
CORS策略已阻止来自源“null”:跨源请求仅支持协议方案:http、数据、chrome扩展、edge、https、chrome untrusted。
我是直接在桌面新建html文件,脚本写入
window.onload = () => {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "te.php", true);//发送的参数
xmlhttp.send();//发送出去了
}
PHP是 te.php
<?php
echo "666"
?>
然后报这个错,是怎么回事?有什么好办法解决吗?