added 支持CORS跨域请求,完善Ajax请求方式

This commit is contained in:
zhaoxiang 2017-02-28 11:06:24 +08:00
parent 9e09f3802e
commit 7f0f18a87e

View File

@ -19,6 +19,7 @@ class Base extends Controller {
public $url; public $url;
public $menuInfo; public $menuInfo;
private $CORS = true;
private $superUrl = [ private $superUrl = [
'User/login', 'User/login',
'User/logout' 'User/logout'
@ -36,6 +37,14 @@ class Base extends Controller {
if(method_exists($this,'_myInitialize')){ if(method_exists($this,'_myInitialize')){
$this->_myInitialize(); $this->_myInitialize();
} }
if( $this->CORS ){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlHttpRequest';
}
} }
/** /**