繁体   English   中英

响应标题缺少字符集

[英]Response Headers missing charset

我动态创建一个表,该表设置了一个按钮来加载“更多信息”类型的模式,由于某种原因,我碰到了这个问题,其中模式不会出现,并且我的错误消息捕获提供了空白信息。

令人困惑的是,即使表中的所有行都完全相同创建,也不会在表中的所有行上都发生。

我可以看到的唯一区别是Content Headers contentType缺少字符集。 但看不到发生这种情况的任何明显模式。

回应的工作范例

错误的回应范例

 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也很明显。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM