在ASP.NET应用程序中使用jQuery Asyncronously负载板 [英] Asyncronously Load Panels using jQuery in ASP.NET application
问题描述
我有一个ASP.net应用程序,其中包含仪表板接口,包括各种数量的面板中。每个面板包含一个HighChart控制,并从不同的数据源加载。有些数据源可能需要一些时间来执行,所以我不想拖慢整个页面的执行,因为一个缓慢的加载数据源。
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.
由于我使用的是高图表来显示我有jQuery的code中的数据类似:
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);
}
});
由于可以在$(文件)。就绪我做一个AJAX调用回服务器检索用来构建图表数据的JSON数据结构可以看出。
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.
这一切工作正常,除了通话不似乎是真正的异步,如果第一个面板加载缓慢,然后随后的面板不加载,直到缓慢第一个面板加载后。为了证明我的面板数据源的1加了Thread.sleep代码。
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.
我也不会,虽然这是情况下我使用Ajax调用。
I wouldn't have though that this was the case as I'm using Ajax calls.
推荐答案
好吧,一旦我有类似的问题。
Well once I had a similar problem
首先尝试加入
async: true,
cache: false
你 AJAX
呼叫
如果不解决您的问题,那么你需要禁用页面上的会话
If that doesn't solve your problem then you need to disable the Session
on the page
<%@ Page EnableSessionState="False" ....
有关更多的信息:
REST WCF服务线程锁在一个ASP.Net网站使用AJAX称为
这篇关于在ASP.NET应用程序中使用jQuery Asyncronously负载板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!