-
25 Feb 2013 6:16 AM #1
Answered: How to make ajax call for every 5 seconds?
Answered: How to make ajax call for every 5 seconds?
Hi All,
I want to make ajax call for every 5 seconds.
Can you guys suggest me how to do that ?
-
Best Answer Posted by Johnny Major
You could use Ext.util.DelayedTask
Example
Code:this.pollTask = new Ext.util.DelayedTask(function(){ Ext.Ajax.request({ url: pollUrl, scope: this, success: function(r) { }, failure: function() { } }); this.pollTask.delay(5000); }, this); this.pollTask.delay(5000);
-
25 Feb 2013 6:29 AM #2
Interval
Interval
Use this :
PS.Code://we store setInterval's return value in case we want to clear the interval later on with clearInterval(myInterval) var myInterval = setInterval(function() { //here you put your AJAX request }, 5000//5 seconds in ms);
of course if it is what you were looking for and I understood you correctly
-
25 Feb 2013 6:36 AM #3
You could use Ext.util.DelayedTask
Example
Code:this.pollTask = new Ext.util.DelayedTask(function(){ Ext.Ajax.request({ url: pollUrl, scope: this, success: function(r) { }, failure: function() { } }); this.pollTask.delay(5000); }, this); this.pollTask.delay(5000);
-
25 Feb 2013 6:52 AM #4
Ext.TaskManager
Ext.TaskManager
According to Sencha docs here : http://docs.sencha.com/core/manual/content/timers.html, the correct way would be to use Ext.TaskManager.
Still I wonder why is it advised to use this solution instead of basic setInterval.
Can anyone explain?
-
25 Feb 2013 9:07 PM #5
Thanks All for your solution


Reply With Quote