Jquery IE中的跨域问题
我目前正在研究一些需要发送跨域ajax请求的东西。 我正在使用jQuery1.7.2和Resteasy。 以下是我的ajax请求:Jquery IE中的跨域问题,jquery,ajax,internet-explorer,cross-domain,resteasy,Jquery,Ajax,Internet Explorer,Cross Domain,Resteasy,我目前正在研究一些需要发送跨域ajax请求的东西。 我正在使用jQuery1.7.2和Resteasy。 以下是我的ajax请求: $.ajax({ url: Configuration.AjaxUrlPrefix + "/rest/conf/saveoption", data: { save_option: JSON.stringify(optionData) }, type: "POST", dataType: 'text',
$.ajax({
url: Configuration.AjaxUrlPrefix + "/rest/conf/saveoption",
data: {
save_option: JSON.stringify(optionData)
},
type: "POST",
dataType: 'text',
success: success,
error: fail,
cache: false
});
我使用拦截器将一些头添加到我的rest响应中:
@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", "*");
}
}
它在Chrome和FF中运行良好,但在IE8和IE9中不起作用。我在IE开发者工具中没有看到任何错误。
有人能帮我吗?IE8-9应该使用XDomainRequest来触发跨域ajax请求,而jQuery本机不支持它,我在jQuery bug tracker上找到了一个问题:
记住xdr传输有一些限制,请查看上面关于jQuery票证的讨论,特别是XDomainRequest有一些限制,因为它不支持凭据。@otakustay谢谢,xdr插件适用于我的Get请求,但不适用于Post请求,我还在处理它。