jQuery 1.7.2を使用していて、別のドメインにPOSTリクエストを行いたいとします。これはPOST要求でなければなりません。しかし、これははInternet Explorerで動作しません(IE9で試しました)。他のすべてのブラウザで動作します。Internet ExplorerでのクロスドメインPOSTリクエストajax
私はこのスクリプトを持っている:
<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>
は、私が戻ってエラーを取得:(IE9を含む)
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT, OPTIONS');
echo json_decode(array('success' => 'yes'));
可能複製([クロスオリジンリソース共有を取得する方法(CORS)POSTリクエストが働い] http://stackoverflow.com/questions/5750696/how-to-get-a-cross-origin -resource-sharing-cors-post-request-working) – Jon
Relavent:http://stackoverflow.com/a/12014195/545328 – 65Fbef05
duplicate:http://stackoverflow.com/questions/13149122/jquery-ajax-cross- domain-form-submission-issues-with- – inf3rno