解決IE9下JQuery的ajax失效的問題


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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM