2013-06-26 87 views
0

我在Chrome中创建了一个AJAX XD请求,调用完成得很好,一切正常,响应我可以获取HTTP标头,但在Firefox中,我不能。我已经声明了所有的起始标头等等。Jquery ajax请求不允许在Firefox上获取响应标头

有人可以帮忙吗?

$.ajax({ 
         url: 'myurl', 
         type: "POST", 
         cache: false, 
         dataType: "text", 
         crossDomain: true, 
         async: true, 
         xhrFields: { 
          withCredentials: false 
         } 
        }) 
        .done(function(value, type, obj) { 
        console.log('success', arguments, obj.getAllResponseHeaders()); 
        }); 

On server it's defined the headers: 
    header('Access-Control-Allow-Credentials: true'); 
    header('Access-Control-Allow-Origin: _URL_'); 
    header('Access-Control-Expose-Headers: some_id,Content-Range'); 

回答

0

这可能是由于Firefox中的一个错误。存在这样的问题的描述和建议的解决方法jQuery的文档中:

http://api.jquery.com/jQuery.ajax/

目前,由于在Firefox的错误,其中.getAllResponseHeaders()返回空字符串虽然.getResponseHeader('内容 - 类型')返回一个非空字符串,不支持使用jQuery自动解码Firefox中的JSON CORS响应。

相关问题