0
点赞
收藏
分享

微信扫一扫

ie9以下兼容ajax跨域访问,解决ie9以下浏览器ajax请求报error拒绝访问方案

那小那小 2022-04-01 阅读 134

解决方案如下:

1、ie9以下兼容ajax跨域访问  
2、ajax请求开始前添加 jQuery.support.cors = true;  允许跨域
3、ie浏览器设置允许通过域访问数据 并且 url为http协议。(设置=>Internet选项=>安全=>自定义级别=>允许通过域访问数据(设置启用))

示例:

                jQuery.support.cors = true;
				$.ajax({
					type: "GET",
					//             cache: false,
					data: {

					},
					url: url, //请求地址
					dataType: "json",
					success: function(res) {
						console.log(res)
					},
					error: function(err) {
						console.log(err)
					}
				});
举报

相关推荐

0 条评论