ラジオボタンは2つ。クリックしたものに応じて、ドロップダウン ボックスにそのデータ セットが読み込まれます。最初にクリックしたものにもよりますが、それはロードに約 1 ~ 2 秒かかりますが、他のものはすぐにロードされます。前後にクリックしても。なぜ、そしてどうすればすぐにロードを停止できるのだろうと思っていました(奇妙なことに、私は知っています)。
$('#rblGenre').change( function() {
$('#ddlSpecificGenre').attr('disabled','disabled').html( '<option>Loading...</option>' )
var genre = $(this + ':checked').val();
$.ajax({
type: 'GET',
url: '../bookGenres.xml',
dataType: 'xml',
success: function( xml ) {
var xmlGenre = $(xml).find( genre );
$('#ddlSpecificGenre').removeAttr('disabled').children().remove();
xmlGenre.children().each( function() {
$('#ddlSpecificGenre').append( '<option>' + $(this).text() + '</option>' );
});
}
});
});
<asp:RadioButtonList ID='rblGenre' runat='server'>
<asp:ListItem Text='Fiction' Value='Fiction'></asp:ListItem>
<asp:ListItem Text='Non-Fiction' Value='Non-Fiction'></asp:ListItem>
</asp:RadioButtonList>
<asp:DropDownList ID='ddlSpecificGenre' runat='server' Enabled='false'>
<asp:ListItem Text='Choose a Genre' Selected='True'></asp:ListItem>
</asp:DropDownList>