Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery IE中的跨域问题_Jquery_Ajax_Internet Explorer_Cross Domain_Resteasy - Fatal编程技术网

Jquery IE中的跨域问题

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请求的东西。 我正在使用jQuery1.7.2和Resteasy。 以下是我的ajax请求:

 $.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上找到了一个问题:

Query团队可能认为XDomainRequest与Ajax接口不完全兼容,因此决定不支持它,但是插件可能是有用的:


记住xdr传输有一些限制,请查看上面关于jQuery票证的讨论,特别是XDomainRequest有一些限制,因为它不支持凭据。@otakustay谢谢,xdr插件适用于我的Get请求,但不适用于Post请求,我还在处理它。