在 ExtJs 中增加 Ajax 请求超时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19563968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Increasing Ajax request timeout in ExtJs
提问by Kabeer
Is there one single configuration in ExtJs library to increase Ajax request timeout?
ExtJs 库中是否有一个配置可以增加 Ajax 请求超时?
I have tried following two configurations but neither helped:
我尝试了以下两种配置,但都没有帮助:
Ext.override(Ext.data.Connection, {
timeout: 60000
});
Ext.Ajax.timeout = 60000;
回答by kevhender
I used the 2 that you mentioned, but also had to override these:
我使用了你提到的 2,但也必须覆盖这些:
Ext.override(Ext.data.proxy.Ajax, { timeout: 60000 });
Ext.override(Ext.form.action.Action, { timeout: 60 });
Update for ExtJS 5:
ExtJS 5 的更新:
It looks like you now need to set the Ext.Ajax timeout using setTimeout()for ExtJS 5+, instead of just setting the property:
看起来您现在需要setTimeout()为 ExtJS 5+设置 Ext.Ajax 超时,而不仅仅是设置属性:
Ext.Ajax.setTimeout(60000);
回答by Snehal Masne
I had to do below one :
我必须做以下之一:
Ext.Ajax.timeout= 60000;
Ext.override(Ext.form.Basic, { timeout: Ext.Ajax.timeout / 1000 });
Ext.override(Ext.data.proxy.Server, { timeout: Ext.Ajax.timeout });
Ext.override(Ext.data.Connection, { timeout: Ext.Ajax.timeout });
回答by Ton Voon
I've found this is the best change for ExtJS 4 (tested on 4.2.3):
我发现这是 ExtJS 4 的最佳更改(在 4.2.3 上测试):
// Connection uses its own timeout value hardcoded in ExtJS - we remove it so that Ext.data.Connection will then
// fallback to using Ext.Ajax.timeout, thus giving a single place for setting the timeout
// Bonus: you can change this at runtime
Ext.define('Monitoring.overrides.Connection', {
override: 'Ext.data.Connection',
constructor: function() {
delete this.timeout;
this.callParent(arguments);
}
});
Ext.define('Monitoring.overrides.ProxyServer', {
override: 'Ext.data.proxy.Server',
constructor: function() {
delete this.timeout;
this.callParent(arguments);
}
});
Now you can use Ext.Ajax.timeout and it will change all the AJAX calls (don't know about form submission).
现在你可以使用 Ext.Ajax.timeout 并且它会改变所有的 AJAX 调用(不知道表单提交)。

