在我的web應用程序中,嘗試使用ajax調用將數據傳遞到另一個域。但它顯示錯誤,如Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://example.com/auth/webschool/test.php. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
CORS header'Access-Control-Allow-Origin'在php中缺少
我的AJAX代碼,
$.ajax({
type: "POST",
url: "http://example.com/auth/webschool/test.php",
data: {username: "abcd",password:"abcd"},
dataType: "html",
success: function (data) {
alert(data);
}
});
所以升級你的PHP文件發送相關'Access-Control-Allow-Origin'頭文件? –
<?php header(「Access-Control-Allow-Origin:*」); header(「Content-Type:text/event-stream」); header(「Cache-Control:no-cache」);?> –