本文實例講述了jQuery實現在下拉列表選擇時獲取json數據的方法。分享給大家供大家參考。具體如下:
function populateDropDown() { $.getJSON('/getData.aspx',{Name:$('#parm').val()},function(data){ var select = $('#DDLControl'); var options = select.attr('options'); $('option', select).remove(); $.each(data, function(index, array) { options[options.length] = new Option(array['variety']); }); });} $(document).ready(function() { populateDropDown(); $('#DDLchangeData').change(function() { populateDropDown(); });});
希望本文所述對大家的jQuery程序設計有所幫助。
新聞熱點
疑難解答