2013-10-24 82 views
10

ExtJs库中是否存在单个配置来增加Ajax请求超时?在ExtJs中增加Ajax请求超时

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

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

Ext.Ajax.timeout = 60000; 

回答

22

我用你提到的2,但也不得不重写这些:

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

更新ExtJS的5:

它看起来像你现在需要设置Ext.Ajax超时使用setTimeout()为ExtJS 5+,而不是只是设置属性:

Ext.Ajax.setTimeout(60000); 
+0

这似乎是工作。谢谢。 – Kabeer

+0

什么时间限制?我正在进行路线计算,我认为这需要很多工作才能完成... –

3

我不得不做以下之一:

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

我发现这是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); 
    } 
}); 

现在你可以使用Ext.Ajax.timeout,它会改变所有的AJAX调用(不知道表单提交)。