jQuery $ .ajax()功能-访问XMLHttpRequest对象 [英] jQuery $.ajax() functionality - Accessing the XMLHttpRequest object
问题描述
是否可以从$.ajax()
函数的成功回调中访问XMLHttpRequest
对象?具体来说,我需要访问IE中的XMLHttpRequest.responseBody
.根据文档,返回的jqXHR
对象不会公开.responseBody
属性.
Is it possible to access the XMLHttpRequest
object from the success callback of the $.ajax()
function? Specifically I need access to XMLHttpRequest.responseBody
in IE. Per the documentation the returned jqXHR
object does not expose the .responseBody
property.
这似乎是一个较小的站点,在处理二进制数据时会产生巨大的影响.如果.responseBody
属性或基础XMLHttpRequest
对象不可访问,我将不得不跳过jQuery for ajax,并将其编码为 shudder (纯JavaScript).
This seems to be a minor oversite that has a huge impact when dealing with binary data. If the .responseBody
property or the underlying XMLHttpRequest
object is not accessible I'll have to skip jQuery for ajax and code it in, shudder, pure javascript.
我实际上是在寻找responceBody
变量,而不是可以从$.ajax()
I am infact looking for the responceBody
variable, not the responceText
variable that is readily accessible from within $.ajax()
推荐答案
您也可以使用beforeSend回调:
You can use beforeSend callback too:
$.ajax({
beforeSend: function(jqXHR, settings){
// Here you are the XHR object
console.log(settings.xhr());
}
});
这篇关于jQuery $ .ajax()功能-访问XMLHttpRequest对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!