我的开发人员控制台中出现此错误:
(index):1 Access to XMLHttpRequest at 'https://www.sigere.site/login/makeLogin?user=admin&pass=123456' from origin 'https://sigere.site' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
我正在执行简单的登录并重定向到codeigniter中的其他页面 那是我的ajax查询
$.ajax({
url: base_url+'login/makeLogin',
type: 'GET',
dataType: 'json',
data: data,
beforeSend:function(){
},
success:function(r){
if(r.response==2){
window.location.replace(base_url+'Admin');
}
},
error:function(xhr, status, msg){
console.log(xhr.responseText);
},
complete: function () {
}
});
我在控制器中的功能是
public function index() {
$this->load->view('registro');
}
答案 0 :(得分:0)
尝试允许
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, OPTIONS");
或将其添加到htaccess文件中。
<FilesMatch ".(eot|ttf|otf|woff)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>