ajax 设置Access-Control-Allow-Origin实现跨域访问

 

<?php
$ret = array(
    'name' => isset($_POST['name'])? $_POST['name'] : '',
    'gender' => isset($_POST['gender'])? $_POST['gender'] : ''
);
 
header('content-type:application:json;charset=utf8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST');
header('Access-Control-Allow-Headers:x-requested-with,content-type');
 
echo json_encode($ret);

 

 

https://blog.csdn.net/fdipzone/article/details/46390573/

posted @ 2019-05-12 21:41  James2019  阅读(3346)  评论(0编辑  收藏  举报