跨域請求錯誤提示以下圖: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); }