简体   繁体   中英

Response Headers missing charset

I create a table dynamically which sets a button to load a 'more info' type modal, for some reason every so oftern I hit this issue where the modal won't appear and my errormessage catch supplies blank info.

The confusing part is it dosn't happen on all of the rows in the table, even though they are all created exactly the same.

The only difference I can see is the Content Headers contentType is missing the charset. but can't see any obvious pattern to why this is happening.

Working Example of Response

Broken Example of Response

 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> 

the filterID function

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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