A solution for Ajax requests to time out when there is a large amount of data

  • 2020-03-30 02:08:34
  • OfStack

< img SRC = "border = 0 / / files.jb51.net/file_images/article/201402/201402271717042.gif? 2014127171724 ">  
Recently, I have been working on a project with EXtjs. When the load of data is extremely large, there will be a load timeout. If I look at it under FB, it turns out that ext's default ajax request is 30 seconds.
Search the Internet for the following solutions for reference and others.

When ExtJS makes an Ajax request, the default response time is 30 seconds, and if the subsequent data query takes longer than 30 seconds, ExtJS will report an error.
This requires modifying the ExtJS timeout:
Two methods:

1: add the (timeout: 100000000) property to the Ajax request
 
Ext.Ajax.request({ 
url: 'foo.php', 
success: someFn, 
failure: otherFn, 
timeout: 100000000,//default 30000 milliseconds 
headers: { 
'my-header': 'foo' 
}, 
params: { foo: 'bar'} 
}); 

Ext.ajax.request ({url: 'foo.php', success: someFn, failure: otherFn, timeout: 100000000,//default 30000 milliseconds headers: {'my-header': 'foo'}, params: {foo: 'bar'}});

2: after the start of js add: ext.ajax.timeout = 180000;
 
Ext.onReady(function() { 
Ext.BLANK_IMAGE_URL = '../../common/ext3/resources/images/default/s.gif '; 
Ext.Ajax.timeout = 180000; 
vardateType;//Report type
Ext.onReady(function() { Ext.BLANK_IMAGE_URL = '../../common/ext3/resources/images/default/s.gif '; Ext.Ajax.timeout = 180000; var dateType;//After testing the report type, the first setting was found to be invalid and the second to be valid.

Too busy relationship, the first test here, think the most should do or to optimize the database, after all, do a query, let the user wait for 3 minutes, is certainly unacceptable. Not for a minute.

Related articles: