簡體   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