ThinkPHP5.0解决Ajax跨域的问题

/*防止跨域*/ 
//允许的请求来源     
header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
//是否允许ajax跨域请求时带上cookie证书
header('Access-Control-Allow-Credentials: true');
//允许的请求方法
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
//表明它允许跨域请求包含Origin, X-Requested-With, Content-Type, Accept, authKey, sessionId头
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, authKey, sessionId");

你可能感兴趣的:(ThinkPHP)