[英]cross-domain issue in IE
I'm current working on some stuff that need to send cross-domain ajax requests. 我目前正在处理一些需要发送跨域Ajax请求的内容。 I'm using jQuery 1.7.2 and Resteasy.
我正在使用jQuery 1.7.2和Resteasy。 Here is my ajax request:
这是我的ajax请求:
$.ajax({
url: Configuration.AjaxUrlPrefix + "/rest/conf/saveoption",
data: {
save_option: JSON.stringify(optionData)
},
type: "POST",
dataType: 'text',
success: success,
error: fail,
cache: false
});
And I use a interceptor to add some headers to my rest responses: 我使用拦截器向其余响应添加一些标头:
@Provider
@ServerInterceptor
public class CrossDomainInteceptor implements PostProcessInterceptor
{
@Override
public void postProcess(ServerResponse response)
{
MultivaluedMap<String, Object> metadata = response.getMetadata();
metadata.add("Access-Control-Allow-Origin", "*");
metadata.add("Access-Control-Allow-Methods", "*");
metadata.add("Access-Control-Max-Age", "*");
metadata.add("Access-Control-Allow-Headers", "*");
}
}
It works well in Chrome and FF, but not work in IE8 and IE9. 它在Chrome和FF中运行良好,但在IE8和IE9中却无法运行。 And I didn't see any error in IE developer tool.
而且我没有在IE开发人员工具中看到任何错误。 Could anyone help me?
有人可以帮我吗?
IE8-9 should use XDomainRequest
to fire cross-domain ajax request and jQuery does not support it natively, I find a ticket on jQuery bug tracker: http://bugs.jquery.com/ticket/8283 IE8-9应该使用
XDomainRequest
触发跨域ajax请求,而jQuery 本身不支持它,我在jQuery Bug跟踪器上找到了一个票证: http : //bugs.jquery.com/ticket/8283
jQuery team may consider XDomainRequest
not completely compatible to its ajax interface so has decided not to support it, however a plugin may be helpful: https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js jQuery团队可能会考虑
XDomainRequest
与它的ajax接口不完全兼容,因此决定不支持它,但是插件可能会有所帮助: https : //github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js
Remember xdr transport has some limitation, check discussion of the jQuery ticket above 记住xdr传输有一些限制,请查看上面有关jQuery票证的讨论
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.