在PHP文件上加上 header("Access-Control-Allow-Origin: *"); //全域名 header("Access-Control-Allow-Credentials: true"); //是否能够携带cookie header("Access-Control-Allow-Methods: POST,GET,PUT,OPTIONS,DELETE"); //容许请求方式 header("Access-Control-Allow-Headers: X-Custom-Header"); //容许请求字段,由客户端决定 header("Content-Type: text/html; charset=utf-8"); //返回数据类型( text/html; charset=utf-八、 application/json; charset=utf-8 )