[轉貼]php API 跨域請求 – IT閱讀

處理PHP API 跨域請求:

設定API相應的http頭,讓該介面支援跨域請求

header(“Content-type: application/json”);
header(“Access-Control-Allow-Origin: *” );
header(“Access-Control-Allow-Methods: GET, OPTIONS, POST”);
header(“Access-Control-Allow-Credentials: true”);
header(“Access-Control-Allow-Headers: Content-Type, Content-Length, Accept-Encoding, X-Requested-With, Origin”);

處理PHP API 跨域請求:設定API相應的http頭,讓該介面支援跨域請求   header(“Content-type: application/json”);   header(“Access-Control-Allow-Origin:  *” );    header(“Access-Control-Allow-Methods: GET, OPTIONS, POST”);    header(“Access-Control-Allow-Credentials: true”);    header(“Access-Control-Allow-Headers: Content-Type, Content-Length, Accept-Encoding, X-Requested-With, Origin”);

內容出處: php API 跨域請求 – IT閱讀