我有一个接口发送(FROMDATE和TODATE)到MSSQ1,并检索选定的详细信息,并且在接收到它们之后,数据将显示在网格上。
我正在使用MVC。
这是我正在使用的js脚本。
$('body').on('submit', '#form', function (e) {
e.preventDefault();
$('#btnSubmit').html('<i class="fa fa-refresh fa-spin" style="font-size:14px"></i> Please wait ....');
$('#btnSubmit').prop('disabled', true);
var fromdate = $('#PeriodFrom').val();
var todate = $('#PeriodTo').val();
if ($('#PeriodFrom').val() > $('#PeriodTo').val())
{
ToastMessage("To date cannot be less than From date ");
return false;
}
debugger;
$.ajax({
url: '/ReservationInquiries/ReservationInquery?fromdate=' + fromdate + '&todate=' + todate,
dataType: 'JSON',
method: 'GET',
beforeSend: function () {
$('#btnSubmit').html('<i class="fa fa-refresh fa-spin" style="font-size:14px"></i> Please wait ....');
$('#btnSubmit').prop('disabled', true);
},
complete: function () {
$('#btnSubmit').html('Save');
$('#btnSubmit').prop('disabled', false);
},
success: function () {
FillGrid();
},
error: function (xhr, status, error) {
console.log(error);
}
});
});
URL:'/ ReservationInquiries / ReservationInquery?fromdate ='+ fromdate +'&todate ='+至今, 当用户选择日期范围时,通过使用以下URL,它将Fromdate和Todate发送给控制器,然后是Service,然后是Entry。
它从MSQL返回返回ReservationNo和Name。
因此,根据我的程序,所有内容均已提取到模型(从MSQL提取的值)。 如您所见,当它重定向回时,我在我的js中调用了一个名为** FillGrid(); **的函数。
function FillGrid()是我用来在HTML中绘制网格的函数。
即使获取了数据,网格上也没有显示任何内容,这是错误的吗? 有人可以帮我吗?
function FillGrid() {
debugger;
if ($('#grid').length == 1) {
$('#grid tr').not(':first-child').remove();
$.ajax({
//url: '/ReservationInquiries/select?search=' + $('#txtSearch').val(),
//dataType: 'JSON',
beforeSend: function () {
$('.grid').hide();
$("#loadingProjects").show();
},
complete: function () {
ShowGrid();
$("#loadingProjects").hide();
},
method: 'POST',
success: function (data) {
debugger
//var inquirieslist = JSON.stringify(data.InqueryList)
$('#grid tr:not(:first)').empty();
if (inquirieslist != null) {
$.each(inquirieslist, function (index, item) {
$('<tr>' +
'<td>' + item.ReservationNo + '</td>' +
'<td>' + item.Name + '</td>' +
'</tr>').appendTo($('#grid'));
});
}
},
error: function (xhr, status, error) {
console.log(error);
}
});
}
}