I have an ASP.net application which contains a dashboard interface which consists of various number of panels. Each Panel contains a HighChart control and is loaded from a different data source. Some of the data source may take some time to execute, therefore I don't want to slow down the overall page execution because of one slow loading data source.
I would like the page to load then each panel to appear when it's data is ready.
As I'm using High charts to display the data I have jQuery code similar to:
$(document).ready(function () {
var panelIDList = dashID.Get("panelList");
for (var i = 0; i < panelIDList.length; i++) {
addpanel(panelIDList[i]);
}
});
function addpanel(panelID)
{
$.ajax({
type: "POST",
url: "Data.aspx/GetData",
data: "{val:'" + panelID + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
var myObject = eval('(' + msg.d + ')');
var options = {
chart: {
renderTo: myObject.renderTo,
type: myObject.chartVal,
height: 300,
width: 600
},
xAxis: {
categories: myObject.xaxis.Categories,
},
series: myObject.serList
};
var chart = new Highcharts.Chart(options);
}
});
As can be seen in $(document).ready I make an Ajax call back to the server to retrieve a JSON data structure which is used to construct the charts data.
This all works fine, except that the calls not seems to be truly asynchronous, if the first panel is slow to load then the subsequent panels aren't loaded until after the slow first panel loads. To demonstrate I've added a Thread.Sleep in 1 of the panels DataSource.
I wouldn't have though that this was the case as I'm using Ajax calls.