我正在尝试从客户端填充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(…)
我做错了什么?相同类型的功能可在另一个项目中使用。
在jQuery 3中,以下函数已从从jqXHR
返回的实例中删除$.get(url)
:
jqXHR.success();
jqXHR.error()
jqXHR.complete()
jqXHR
文档中的弃用通知要求改为使用以下内容:
jqXHR.done()
jqXHR.fail()
jqXHR.always()
(记录在同一页上)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句