我动态创建一个表,设置一个按钮来加载'更多信息'类型模式,出于某种原因,每个人都这样,我遇到了这个问题,模态不会出现,我的errormessage catch提供空白信息。
令人困惑的部分是它不会发生在表中的所有行上,即使它们都是完全相同的。
我能看到的唯一区别是Content Headers contentType缺少charset。但是看不出任何明显的模式来解释为什么会发生这种情况。
function filterData() {
//$('#InfoAlert').fadeOut('slow');
var res = validateFilter();
if (res === false) {
return false;
}
var almObj = {
DateTime: $('#datetimepicker1').find('input').val(),
Shift: $('#shift').val(),
Text7: $('#area').val()
};
$.ajax({
url: "/Home/filterList/",
data: JSON.stringify(almObj),
type: "POST",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function(result) {
$('#AlarmSummary').fadeOut('fast');
$('#Table').fadeOut('fast');
var html = '';
$.each(result, function(key, item) {
//Color the rows depending on time
var cellcolor = 'black'
if (item.TimeDiff >= 30) {
cellcolor = 'orange';
}
if (item.TimeDiff > 60) {
cellcolor = 'red';
}
//TODO: Remove pointless variable...
var CounterID = item.Counter;
//Display TimeDiff as minutes and seconds.
var date = new Date(null);
date.setSeconds(item.TimeDiff);
var utc = date.toUTCString();
var time = utc.substr(utc.indexOf(':') - 2, 8);
//build table
html += '<tr>';
html += '<td width="15%">' + item.DateTime + '</td>';
html += '<td width="15"><strong>' + item.Text2 + '</strong></td>';
html += '<td width="40%">' + item.Text6 + '</td>';
html += '<td width="15%"><font color=' + cellcolor + '>' + time + '</font></td>';
html += '<td width="15%"><a onclick="return filterID(' + CounterID + ')"><button type="button" class="btn btn-default"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Comment</button></a></td>';
html += '</tr>';
});
$('.tbody').html(html);
$('#Table').fadeIn('fast');
},
error: function(errormessage) {
alert(errormessage.responseText);
}
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<br />
<div class="table-responsive" id="Table">
<table class="table table table-hover table-condensed searchable">
<thead>
<tr data-cell-style="cellStyle">
<th>
Date Time
</th>
<th>
Facility
</th>
<th>
Concern
</th>
<th>
Downtime
</th>
<th>
Update
</th>
</tr>
</thead>
<tbody class="tbody"></tbody>
</table>
</div>
</div>
filterID函数
function filterID(ID) {
$('#CommentWarning').hide();
$('#PText3Warning').hide();
$('#Text8Warning').hide();
var Counter = ID;
var DateTime = $('#datetimepicker1').find('input').val();
var Shift = $('#shift').val();
var Text7 = $('#area').val();
$.ajax({
type: "GET",
dataType: "json",
url: "/Home/filterID/",
data: {
"Counter": Counter,
"DateTime": DateTime,
"Shift": Shift,
"Text7": Text7
},
success: function(result) {
//Display TimeDiff as minutes and seconds.
var date = new Date(null);
date.setSeconds(result.TimeDiff);
var utc = date.toUTCString();
var time = utc.substr(utc.indexOf(':') - 2, 8);
$('#Counter').val(result.Counter);
$('#DateTime').val(result.DateTime);
$('#Comment').val(result.Comment);
$('#Text2').val(result.Text2);
$('#Text6').val(result.Text6);
$('#PText3').val(result.PText3);
$('#Text8').val(result.Text8);
$('#TimeDiff').val(time);
$('#myModal').modal('show');
$('#btnUpdate').show();
},
error: function(errormessage) {
alert(errormessage.responseText);
}
});
return false;
}
答案 0 :(得分:0)
这是一个数据库问题,结果集基本上也是0,内容长度为0。