1
我試圖創建級聯DDL。試圖使用JSON獲得級聯DDL但沒有得到響應
我的aspx頁面:
<form id="form1" runat="server">
<table>
<tr>
<td>סוג שולחן</td>
<td><asp:DropDownList ID="ddlTableType" runat="server" /></td>
</tr>
<tr>
<td>קוד שולחן</td>
<td><asp:DropDownList ID="ddlTableCode" runat="server" /></td>
</tr>
<tr>
<td>הנחה קבועה לשולחן</td>
<td><asp:DropDownList ID="ddlDiscounts" runat="server" /></td>
</tr>
</table>
</form>
我從填充DB第一DDL和工作正常。現在
,對於第二DDL我正在使用此代碼:
$(document).ready(
function()
{
$("#ddlTableType").change(
function()
{
$('#ddlTableCode').html('');
var TypeID = $("#ddlTableType > option:selected").attr("value");
$.getJSON('LoadTableCodes.ashx?ObjectType=' + TypeID, function(TableCodes) {
alert('aaaaaaaaaaaaaa');
$.each(TableCodes, function() {
alert(this['TableCode']);
$("#ddlTableCode").append($("<option></option>").val(this['TableCode']).html(this['TableCode']));
});
});
}
);
}
);
當我瀏覽到LoadTablesCodes與typeId我得到JSON resould。這是工作...
我的問題是與js代碼,我認爲,我的$ .getJSON功能不工作(甚至不能獲取彈出功能內部的警報)。
請問我做錯了什麼?
10X
t-shooting tips:(1)是.change()被調用嗎? (2)使用fiddler(http://www.fiddler2.com/fiddler2/)檢查是否發送了json請求,以及是否回覆了回覆。 – 2010-10-03 00:22:34
是的,更改()正在調用,當我把警報爲getJSON彈出... – Erez 2010-10-03 00:38:48
你試過Firebug嗎? http://getfirebug.com/ – 2010-10-04 12:58:00