example.com我正在使用以下代码:
$.ajax({
type: "GET",
url: "http://www.example.com/login.php",
headers: {
"x-csrf-token": window.sailsToken
},
success: function(response) {
console.log(response);
}
});
如果文件在服务器上联机,则效果很好。
但是,在localhost-call(htttp://localhost/myfile.html)上,我将收到跨域错误。
php文件内容:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
如果我删除了行"标题......"在ajax-call中,它的效果也很好。
有没有机会让它在localhost模式下运行?