我一直在從JavaScript獲取此錯誤。每次我選擇/取消選擇ckhDirectDebit複選框都會發生。未捕獲RangeError:在Chrome中超出最大調用堆棧大小
下面是代碼:
<script type="text/javascript">
$(document).ready(function() {
var isDirectDebitSelected = $('#<%=chkDirectDebit.ClientID%>');
var sameAsMerchantBankCheckbox = $('#<%=chkSameAsMerchantBank.ClientID%>');
var sameAsMerchantBankLabel = $('#<%=txtSameAsMerchantBank.ClientID%>');
function setSameAsMerchantVisible() {
if (isDirectDebitSelected.is(':checked')) {
sameAsMerchantBankCheckbox.show();
sameAsMerchantBankLabel.show();
} else {
sameAsMerchantBankCheckbox.hide();
sameAsMerchantBankLabel.hide();
}
isDirectDebitSelected.bind('change', function() {
setSameAsMerchantVisible();
});
setSameAsMerchantVisible();
}
});
</script>
<asp:CheckBox runat="server" ID="chkDirectDebit" />
<asp:Label runat="server" AssociatedControlID="chkSameAsMerchantBank" ID="txtDirectDebit" meta:resourcekey="lblDirectDebit"></asp:Label>
<asp:CheckBox runat="server" ID="chkSameAsMerchantBank" OnCheckedChanged="chkSameAsMerchantBank_CheckedChanged" AutoPostBack="True" Checked="True" />
<asp:Label runat="server" AssociatedControlID="txtSameAsMerchantBank" ID="txtSameAsMerchantBank" meta:resourcekey="lblSameAsMerchantBank"></asp:Label>
任何人都知道我在JS做什麼錯?導致這種異常的潛在問題是什麼?
'setSameAsMerchantVisible'總是叫你得到無限遞歸調用 – Grundy
'setSameAsMerchantVisible()''從setSameAsMerchantVisible',你有什麼期待? ? –
@ A.Wolff我試圖檢查chkDirectDebit是否被檢查。如果它比我需要調用setSameAsMerchantVisible方法,那需要顯示chkSameAsMerchantBank複選框。 –