在ExtJs中增加Ajax请求超时

时间:2023-01-22 18:56:49

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;

3 个解决方案

#1


23  

I used the 2 that you mentioned, but also had to override these:

我用了你提到的两个,但也必须重写这些

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:

现在,您需要使用ExtJS 5+来设置Ext.Ajax超时,而不是只设置属性:

Ext.Ajax.setTimeout(60000);

#2


3  

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 });

#3


0  

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了。超时,它将改变所有的AJAX调用(不知道表单提交)。

#1


23  

I used the 2 that you mentioned, but also had to override these:

我用了你提到的两个,但也必须重写这些

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:

现在,您需要使用ExtJS 5+来设置Ext.Ajax超时,而不是只设置属性:

Ext.Ajax.setTimeout(60000);

#2


3  

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 });

#3


0  

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了。超时,它将改变所有的AJAX调用(不知道表单提交)。