php:
function __construct()
{
// 指定允许其他域名访问
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
header('P3P: CP="CAO PSA OUR"'); // Makes IE to support cookies
header("Content-Type: application/json; charset=utf-8");
}
ajax:
dataType:'jsonp', //ajax跨域返回的数据格式不同,所有要用jsonp格式接收