我有這樣的代碼:jQuery的填充下拉列表
$(document).ready(function() {
var mddlrole = $('<%=ddlrole.ClientID %>');
$.ajax({
type: "POST",
url: "ReportBasic.aspx/getroledata",
data: '{}',
contentType: "application/json;",
dataType: "json",
success: function(response) {
debugger;
alert(response.d);
$(response.d.toString()).find('Table').each(function() {
var OptionValue = $(this).find('RoleID').text();
var OptionText = $(this).find('Name').text();
alert(OptionValue);
var option = $("<option>" + OptionText + "</option>");
option.attr("value", OptionValue);
mddlrole.append(option);
});
}
});
});
當我提醒response.d
我檢查,如果數據被成功地從服務器來了,但是當我提醒OptionValue
它是未來爲空白。
顯示你在'response.d'得到並學習使用'console.log()' – Satpal 2014-08-27 12:59:48
請不要使用alert()作爲故障排除設備,請改用console.log()。 http://stravid.com/en/stop-the-javascript-alert-madness/ – 2014-08-27 13:00:16
我附上response.d image.please檢查 – 2014-08-27 13:04:25