var kunnr;$(document).ready(function () { $('#NAME1').autocomplete({ source: function (request, response) { $.ajax({ url: "Form2", method: 'POST', data: { term: $('#NAME1').val() }, success: function (data) { response(data); } }); }, select: function (event, ui) { kunnr = ui.item.kunnr; $.ajax({ url: "Form3", method: 'POST', data: { kunnr: kunnr }, success: function (data) { var selectData = JSON.parse(data);//use JSON.parse(), if the data is not already json formatted $("#Subaccount").empty(); selectData.forEach(function (obj) { //NOTE the Value and Text are what you assigned them when you fetched them $('#Subaccount').append($('<option></option>').val(obj.Value).html(obj.Text)); }); } }); } });});
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)