您的位置:首页 > Web前端 > JQuery

ie9 ajax 跨域请求不了 提交为空 jquery-ajaxtransport-xdomainrequest

2017-07-12 14:27 861 查看
本问出自:

http://blog.csdn.net/wyk304443164

几种方式:

可以手动修改ie9的允许跨域访问(不实际)

使用jquery-ajaxtransport-xdomainrequest

api这边

https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest

// GET
$.getJSON('http://jsonmoon.jsapp.us/').done(function(data) {
console.log(data.name.first);
});

// POST
$.ajax({
url: 'http://frozen-woodland-5503.herokuapp.com/cors.json',
data: 'this is data being posted to the server',
contentType: 'text/plain',
type: 'POST',
dataType: 'json'
}).done(function(data) {
console.log(data.name.last);
});


注意:如果post提交东西为空那么可以修改为:

// contentType: 'text/plain',
contentType: 'application/x-www-form-urlencoded',


cdn:

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ie 9 ajax 跨域