我有这样的代码: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