后台是PHP的,需要怎么设置服务端的header?下面是目前的设置。ass_token 是自定义的请求头。
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Headers : accept, ass_token, content-type');
header('Access-Control-Request-Method: GET, POST, PUT, DELETE');
header('Access-Control-Max-Age', '3600');
后端返回的时候添加Access-Control-Allow-Origin头信息,就能支持跨域请求。
服务端使用jquery的ajax需要增加crossDomain: true,参数