ExtJS AJAX获取原始响应文本

时间:2022-10-09 07:32:35

I am making an AJAX call in ExtJS 4, which some users have reported fails without showing any error messages. Looking at the response object, the code is 0 and the responseText is blank. My best guess is that the server is for some reason returning something that is not properly formatted as JSON.

我正在ExtJS 4中进行AJAX调用,一些用户报告失败但没有显示任何错误消息。查看响应对象,代码为0,responseText为空。我最好的猜测是,服务器由于某种原因返回了一些格式不正确的JSON。

How can I get the raw response text if it is not formatted as JSON?

如果原始响应文本未格式化为JSON,如何获取原始响应文本?

2 个解决方案

#1


0  

You could override the Ext.data.Connection to grab the data when it is returned, and before it is processed in any way. I would guess that Andrei is right with his diagnosis, but if you aren't so sure...

您可以覆盖Ext.data.Connection以在返回数据时以及在以任何方式处理数据之前获取数据。我猜安德烈对他的诊断是正确的,但如果你不太确定......

#2


0  

You should be able to get everything you need like this:

你应该能够得到你需要的一切:

Ext.Ajax.request({
url : 'someUrl',
listeners : {
    requestexception : function( conn, response, options, eOpts ){
    console.log(response);
    }

}
});

Status 0 should give you Communication Failure in response.operation.error.statusText ... just console.log(response) and start looking for the significant property for you I wouldn't go to raw unless no other option.

状态0应该在response.operation.error.statusText中给你通信失败...只是console.log(响应)并开始为你寻找重要属性我不会去原始,除非没有其他选项。

Regards.

#1


0  

You could override the Ext.data.Connection to grab the data when it is returned, and before it is processed in any way. I would guess that Andrei is right with his diagnosis, but if you aren't so sure...

您可以覆盖Ext.data.Connection以在返回数据时以及在以任何方式处理数据之前获取数据。我猜安德烈对他的诊断是正确的,但如果你不太确定......

#2


0  

You should be able to get everything you need like this:

你应该能够得到你需要的一切:

Ext.Ajax.request({
url : 'someUrl',
listeners : {
    requestexception : function( conn, response, options, eOpts ){
    console.log(response);
    }

}
});

Status 0 should give you Communication Failure in response.operation.error.statusText ... just console.log(response) and start looking for the significant property for you I wouldn't go to raw unless no other option.

状态0应该在response.operation.error.statusText中给你通信失败...只是console.log(响应)并开始为你寻找重要属性我不会去原始,除非没有其他选项。

Regards.