- 设置浏览器安全属性,启用【通过域访问数据源】选项,如图:
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: 'POST',
cache: false,//关闭缓存
crossDomain: true == !(document.all),//一定要取反
success: function(txt) {
alert(txt);
}
});
});
</script>
</head>
<body>
IE7 thru IE10 CORS Example Using jQuery
</body>
</html>