【发布时间】:2017-03-21 21:31:15
【问题描述】:
在我的 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).这样的错误
我的 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 ajax cross-domain