1. 程式人生 > >jquery ajax在跨域訪問post請求的時候,ie9以下無效(包括ie9)

jquery ajax在跨域訪問post請求的時候,ie9以下無效(包括ie9)

1. 設定瀏覽器安全屬性,啟用【通過域訪問資料來源】選項,如圖:

 


2.呼叫ajax方法時,設定crossDomain為相反的值。原文連結:https://bugs.jquery.com/ticket/12097

<!DOCTYPE html>
<html>
<head>
<title>jQuery CORS in IE7 - IE10</title>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script>
$(document).ready(function() {
$.ajax({
url: "http://dreamfactorysql.cloudapp.net/API/index.php",
dataType: "text",
async: true,
type: 'GET',
cache: false,
crossDomain: true == !(document.all),
success: function(txt) {
alert(txt);
}
});
});
</script>
</head>
<body>
IE7 thru IE10 CORS Example Using jQuery
</body>
</html>