我有一個帶有按鈕的頁面,我想通過按一下按鈕來異步加載2個帶有數據的數據網格。這是頁面的代碼,我使用jquery調用其他2個頁面,這些頁面將產生html。<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Solutions_CashCenter_StockManagement_Test_Test" %><asp:Content ID="Content2" ContentPlaceHolderID="cphCenter" Runat="Server"><style type="text/css"> #wait { position:absolute; top:0px; right:10px; width:200px; z-index:1000; vertical-align:middle; text-align:center; background: #febf00; display:none;}</style><script src='<%= ResolveUrl("../../../../Scripts/jquery-1.4.1.js") %>' type="text/javascript"></script><script type="text/javascript"> $(function () { $('#wait') .ajaxStart(function () { $(this).show(); }) .ajaxStop(function () { $(this).hide(); }); $('input:button').live('click', loadData); }); function loadData() { $.get("Source.aspx", {}, function (data) { $('#a1').html(data); }, "html"); alert('This alert is asynchronous (1st)'); $.get("Source2.aspx", {}, function (data) { $('#a2').html(data); }, "html"); alert('This alert is asynchronous (2nd)'); }</script><div id="test13"> <input type="button" id="btnLoad" value="Load" /></div><div id="a1"></div><div id="a2"></div><div id="wait">Please wait <img src="ajax-loading.gif" /></div></asp:Content>服務器端:Thread.Sleep(5000);dsTest.SelectCommand = "SELECT 'test1', 'test2', 'test3'";this.gridTest.DataSourceID = "dsTest";this.gridTest.DataBind();第二頁相同,但網格數據不同。我得到的結果是兩個警報都同時發生,但是網格是一個接一個地加載的,即第一個網格在5秒鐘后出現,然后第二個網格在另一個5秒鐘后出現。那是服務器實際上并不并發處理它們。我在做什么錯了,我應該如何組織所有人按需工作?
- 2 回答
- 0 關注
- 489 瀏覽
添加回答
舉報
0/150
提交
取消