みなさんこんにちは!アクセス制御 - 許可 - 元はPHPから送信されません
ここでは、同様の問題で多くの質問が調査されていますが、それらは全く異なり、何も機能しません。 質問の著者が制御していない、サードパーティのリソースに問題があり、私の場合、私は強制的にサーバーからヘッダを送信するが、何も受信しない午前: No 'Access-Control-Allow-Origin' header is present on the requested resource error
私はCORSリクエストに問題があります。 PHPの非常に初め
$.ajax({
type: "POST",
url: "http://domain.com/module/api/storeData.php",
data: 'data='+results,
dataType: "html",
async: false,
crossDomain: true,
success: function(msg){
if(msg=="Ok")
{
$("#resultsPane").append ("Results successfully sent.");
} else {
$("#resultsPane").append (msg);
}
},
error: function (xhr, status, errorT)
{
$("#resultsPane").append ("AJAX error: "+status+": "+errorT);
}
});
::ここでは(jQueryのを使用して)私のJSです
<?php
header ("Access-Control-Allow-Origin", "*");
しかし、結果は(コンソールで)です:
jquery.js:10254 XMLHttpRequest cannot load http://domain.com/module/api/storeData.php . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:63342 ' is therefore not allowed access.
レスポンスヘッダ:
Connection:Keep-Alive
Content-Length:2
Content-Type:text/html
Date:Thu, 13 Oct 2016 13:19:23 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.7 (Ubuntu)
X-Powered-By:PHP/5.5.9-1ubuntu4.17
ブラウザのAJAXエラー:
AJAX error: error: NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load ' http://domain.com/module/api/storeData.php '.
誰かが何がうまくいかないのか分かっていますか?前もって感謝します!
'header(" Access-Control-Allow-Origin:* ");'許可する特定のホストを指定することを検討してください。 –
あなたは 'header'を間違って使用しています。 http://php.net/header –
要求されたリソースエラーに[No 'Access-Control-Allow-Origin]ヘッダーが存在する可能性があります](http://stackoverflow.com/questions/28547288/no-access-制御許可元ヘッダーはリソース要求エラー時に表示されます) –