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

来源:互联网 发布:淘宝店的装修 编辑:程序博客网 时间:2024/05/18 00:34

本问出自:

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>
原创粉丝点击