解决JS跨域请求问题

    //下面文件是解决JS跨域请求问题
	header('Access-Control-Allow-Methods:OPTIONS, GET, POST');
	header('Access-Control-Allow-Headers:x-requested-with');
	header('Access-Control-Max-Age:86400');
	$_SERVER['HTTP_ORIGIN'] = isset($_SERVER['HTTP_ORIGIN'])?$_SERVER['HTTP_ORIGIN']:0 ;
	header('Access-Control-Allow-Origin:'.$_SERVER['HTTP_ORIGIN']);
	header('Access-Control-Allow-Credentials:true');
	header('Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS');
	header('Access-Control-Allow-Headers:x-requested-with,content-type');
	header('Access-Control-Allow-Headers:Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With');
    //上面文件是解决JS跨域问题

猜你喜欢

转载自blog.csdn.net/zhangchb/article/details/80494457