配置请求头允许跨域
header('Content-Type:text/json;charset=utf-8');
header('Access-Control-Allow-Origin:*');
header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
header('Access-Control-Allow-Methods:POST,GET');
header('Access-Control-Expose-Headers:*');
拦截OPTIONS请求
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'OPTIONS') {
exit;
}
接收POST请求参数
$postData = json_decode(file_get_contents("php://input"));
$uid = $postData->uid;