PHP端支持跨域.php protected function ajaxxPHP() { //支持跨域 header('Access-Control-Allow-Headers: Content-Type, Authorization'); header('Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, DELETE'); header('Access-Control-Allow
protected function ajaxxPHP() { //支持跨域 header('Access-Control-Allow-Headers: Content-Type, Authorization'); header('Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, DELETE'); header('Access-Control-Allow-Origin: *'); header('Access-Control-Max-Age: 2592000'); //1个月内不需要再发送OPTIONS预检查请求 if (REQUEST_METHOD == 'OPTIONS') { header("HTTP/1.1 204 No Content"); //OPTIONS请求返回空内容的204状态码 exit(); } //检查IP if ($this->checkIP()) { APIResponse::error('IP禁止访问,请联系管理员'); } parent::_initialize(); // TODO: Change the autogenerated stub //检查传递的company_id参数 if (!is_numeric(self::getRequestCompanyId()) || self::getRequestCompanyId() < 0) { ALog::info('当前接口未传递企业ID'); //APIResponse::error('未传递正确的企业ID'); } }