jQuery 1.7.2 を使用していますが、別のドメインに POST リクエストを送信したいと考えています。POST リクエストである必要があります。しかし、これはInternet Explorer では機能しません(IE9 で試しました)。他のすべてのブラウザで動作します。
私はこのスクリプトを持っています:
<script>
jQuery.support.cors = true;
jQuery(function() {
$.ajax({
crossDomain : true,
cache: false,
type: 'POST',
url: 'http://someotherdomain/test.php',
data: {},
success: function(da) {
console.log(JSON.stringify(da))
},
error: function(jqxhr) {
console.log('fail')
console.log(JSON.stringify(jqxhr))
},
dataType: 'json'
});
});
</script>
エラーが返されます:
{"readyState":0,"status":0,"statusText":"Error: Access denied.\r\n"}
私のPHPファイルは次のようになります。
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT, OPTIONS');
echo json_decode(array('success' => 'yes'));