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>

 

posted @ 2016-07-21 10:32  sueris  阅读(2083)  评论(0编辑  收藏  举报