I would like to perform multiple actions at a time in my dashboard. What I did is as below.
I have dashboard which refreshes using .ajax call every 15 seconds, second ajax call starts after 15 seconds on complete of previous call.
I am using async: true
in my method.
Now, there are more other ajax calls events written on that page, my problem is when I click on any other detail report on page at same time of that 15 second call starts.. it keeps me wait and only loads my report when that 15 seconds call finishes.
I dont want to keep in wait to user, when my continuous call starts (15 seconds), I should be able to load any other report and able to call any other ajax methods during that time.
Because, that 15 second call might take 5-10 seconds to get data.. It keeps me in wait.
Below are my code snippet of every 15 seconds.
//Load Live Data event
function GetLiveData() {
$.ajax({
type: 'POST',
contentType: 'application/json; charset=utf-8',
dataType: 'JSON',
async: true,
cache: false,
data: JSON.stringify({ params }),
url: url,
success: function (result) {
// do soemthing
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
},
complete: function (xhr, status) {
//Auto Refresh Data functionality JS
setTimeOutvar = setTimeout(AutomaticRefreshFunction, RefreshIntervalTime);
//End of Auto Refresh JS
}
});
}
Please suggest, should I use async of MVC 5 or any other alternative?
It is not duplicate of what is suggested.. as I mentioned..
I have one ajax call at every 15 seconds, and that call takes 5-10 seconds to load data, so during that time, If I click on any other button to view data/report - it waits for that regular 15 sec. call. I should not wait and load irrespective to that call.