В моем веб-приложении попробуйте передать данные в другой домен с помощью 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({
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»);?> –