跨域请求错误提示以下图:php
解决方法在请求的php页面添加header头:json
代码以下:跨域
public function test() { //支持全域名访问,不安全,部署后须要固定限制为客户端网址 header('Access-Control-Allow-Origin:*'); //支持的http 动做 header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); //响应头 请按照本身需求添加。 header('Access-Control-Allow-Headers:x-requested-with,content-type'); $arr = Querys::selects("index_goods"); echo json_encode($arr); }