Home > Backend Development > PHP Tutorial > javascript - jquery ajax ie8下跨域cookie的问题

javascript - jquery ajax ie8下跨域cookie的问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:22:37
Original
1692 people have browsed it

<code>$.support.cors = true;
$.ajax({
    crossDomain:true,
    xhrFields:{
        withCredentials:true
    },
    data: {aa:"aa"},
    dataType:"json",
    type:"POST",
    ...
});</code>
Copy after login
Copy after login

ie8下到底怎么处理?(jquery1.11.3,也用了相关的transport插件)
后端是php,已经做了crossDomain的设置,在主流浏览器下是ok的

回复内容:

<code>$.support.cors = true;
$.ajax({
    crossDomain:true,
    xhrFields:{
        withCredentials:true
    },
    data: {aa:"aa"},
    dataType:"json",
    type:"POST",
    ...
});</code>
Copy after login
Copy after login

ie8下到底怎么处理?(jquery1.11.3,也用了相关的transport插件)
后端是php,已经做了crossDomain的设置,在主流浏览器下是ok的

ie9及以下的XMLHttpRequest没有CORS的特性,所以 ie9 ie8会使用 XDomainRequest 来达到CORS的效果,而ie7及以下就完全无解了,自然 withCredentials 特性在IE9及以下的版本都不会有实现。
如果仅仅只是获取数据,可以考虑jsonp,提交数据的话就使用form提交到隐藏frame吧,如果跨了根域,那就比较无解了,实现方式很绕,需要在两边域名下都部署页面再通过window.name来做数据传递。
让客户升级浏览器吧~不要在低版本浏览器上浪费生命了

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template