我正在尝试从客户端填充SelectList。 这是我的代码。
function loadSched() {
var dsId = $(this).val();
$('#ScheduleId option:not(:first)').remove();
$.get('/Appointments/GetSchedulesForDoctor?docId=' + dsId)
.success(function (gn) {
// alert('start');
$.each(gn, function () {
$('#ScheduleId').append($('<option/>', { value: this.Value }).text(this.Text));
});
// alert('end');
});
};
function initCreate() {
$('#DoctorId').on('change', loadSched);
};
$(document).ready(function () {
initCreate();
});
/Appointments/GetSchedulesForDoctor?docId=
此路径正确返回json。所以没有问题。我正在尝试的是在#DoctorId更改时填充#ScheduleId。
开发人员控制台发现错误为Uncaught TypeError: $.get(...).success is not a function(…)
我做错了什么?相同类型的功能在另一个项目中起作用。
答案 0 :(得分:0)
怎么样
$.each(gn, function () {
var option = $("<option>");
option.attr("value", this.Value).attr("text", this.Text);
$('#ScheduleId').append(option);
});
答案 1 :(得分:0)
在jQuery 3中,从jqXHR
返回的$.get(url)
实例中删除了以下函数:
jqXHR.success();
jqXHR.error()
jqXHR.complete()
jqXHR
documentation中的弃用通知说使用以下内容代替:
jqXHR.done()
jqXHR.fail()
jqXHR.always()
(在同一页上记录)。