14

ExtJs 库中是否有一个配置可以增加 Ajax 请求超时?

我尝试了以下两种配置,但都没有帮助:

Ext.override(Ext.data.Connection, {
    timeout: 60000
});

Ext.Ajax.timeout = 60000;
4

3 回答 3

26

我使用了您提到的 2,但也必须覆盖这些:

Ext.override(Ext.data.proxy.Ajax, { timeout: 60000 });
Ext.override(Ext.form.action.Action, { timeout: 60 });

ExtJS 5 的更新:

看起来您现在需要setTimeout()为 ExtJS 5+ 设置 Ext.Ajax 超时,而不仅仅是设置属性:

Ext.Ajax.setTimeout(60000);
于 2013-10-24T11:49:21.503 回答
5

我必须做以下一项:

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 });
于 2015-08-10T10:35:02.070 回答
1

I've found this is the best change for ExtJS 4 (tested on 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).

于 2015-09-11T11:13:14.590 回答