解决IE9下JQuery的ajax失效的问题

来源:互联网 发布:mac能用latex吗 编辑:程序博客网 时间:2024/05/16 06:34

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>


阅读全文
0 0
原创粉丝点击