2
我使用ajax jquery
來請求aspx
頁面,並且此頁面顯示GidView
,因此響應將是網格視圖的html代碼。並且我將響應添加到DIV以顯示結果,當我在第一次發出請求時正常工作,但第二次沒有從響應中添加任何內容,儘管存在要綁定的數據。如何使用jquery ajax顯示來自aspx頁面的響應
**此問題僅出現在FireFox的IE瀏覽器中,它可以! **
AJAX請求:
function getSubTraning(mainId) {
$(".res" + mainId).html("");
startLoad();
$.ajax({
url: "ajax/GetSubTraining.aspx",
data: { mainId: mainId },
success: function (a) {
stopLoad();
$(".res" + mainId).append(a);
}
});
}
GetSubTraining.aspx HTML代碼
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="GetSubTraining.aspx.vb" Inherits="Admin_ajax_GetSubTraining" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<form id="form1" runat="server">
<div>
<asp:GridView ID="gvSubTraning" runat="server"
AutoGenerateColumns="False"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None"
BorderWidth="1px"
CellPadding="4" EnableModelValidation="True"
ForeColor="Black"
GridLines="Horizontal" Width="100%" DataSourceID="SqlDataSource1">
<EmptyDataTemplate>
No sub training to view !
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="Train_S_Desc_Ar"
HeaderText="Sub training needs"
SortExpression="Train_S_Desc_Ar">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Width="95%" />
</asp:BoundField>
<asp:TemplateField ShowHeader="False">
<ItemStyle Width="5%" />
</asp:TemplateField>
<asp:TemplateField SortExpression="Train_S_Indx">
<ItemTemplate>
<input type="button" class='btnRemoveSub' title="<%# Eval("Train_S_Indx") %>-<%# Eval("Train_M_Indx") %>" value="Remove" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Train_S_Indx") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
<%-- <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />--%>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Con_New %>"
SelectCommand="getSubTtraining" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter Name="mainId" QueryStringField="mainId"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>