解决H5读取接口的跨域问题

ob_start();//清空缓冲区
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST, GET, OPTIONS, PUT, DELETE');
header('Access-Control-Max-Age:1728000');

if($_SERVER['HTTP_ACCEPT'] == "OPTIONS"){
header('Access-Control-Allow-Headers:Content-Type, Accept, Authorization, X-Requested-With, X_Requested_With, Origin');
header('Access-Control-Request-Method:*');
}

posted @ 2018-05-09 17:49  fantasy0810  Views(3412)  Comments(0)    收藏  举报