当前位置:Gxlcms > PHP教程 > php跨域

php跨域

时间:2021-07-01 10:21:17 帮助过:9人阅读

跨域待测 isset($_POST['name'])? $_POST['name'] : '',    'gender' => isset($_POST['gender'])? $_POST['gender'] : '');header('content-type:application:json;charset=utf8');$origin = isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN'] : '';$allow_origin = array(    'http://www.client.com',    'http://www.client2.com');if(in_array($origin, $allow_origin)){    header('Access-Control-Allow-Origin:'.$origin);    header('Access-Control-Allow-Methods:POST');    header('Access-Control-Allow-Headers:x-requested-with,content-type');}echo json_encode($ret);?>

转自:

人气教程排行