When using datatable, the value returned by the background to the foreground will be empty. At this time, the foreground will report an error. Here are the prevention methods
$('#datatable1').DataTable( { ajax: { "url": 'list', "type": "POST", data:{ title : function(){ return $("#title").val(); } } }, columnDefs: [{"defaultContent": "", "targets": "_all"}], columns: [ { title: "序号", render:function(data,type,row,meta){ return meta.row + 1 + meta.settings._iDisplayStart }, width:"5%" }, { title: "推送类型", data:"mp_send_type", width:"5%" }, //x { title: "推送标题", data:"mp_msg_title", width:"15%" }, { title: "任务ID(TASK id)", data:"mp_taskid", width:"12%" },//x */ { title: "推送时间", data:"mp_send_time", width:"7%" }, //x { title: "推送人数", data:"mp_count", width:"5%" }, //x { title: "操作人", data:"mp_admin_user_name", width:"7%" }, // x { title: "状态", render:function(data, type, row){ var str = ""; if(row.mp_status == "1"){ str = "<span class='label label-warning'>推送中</span>"; }else if(row.mp_status == "2"){ str = "<span class='label label-success'>推送完成</span>"; }else{ str = "<span class='label label-warning'>推送失败</span>"; } return str; } , width:"10%"} ] ,serverSide: true ,paging:true ,pagingType: "simple_numbers" ,lengthChange: true ,ordering:false ,info:false ,pageLength:10 ,searching: false ,language: { "url": "<%=contextPath %>/static/backend/js/Chinese.lang" } });
Intermediate:
columnDefs: [{"defaultContent": "", "targets": "_all"}],
This means that no error will be reported when the default value is set to null
Similar Posts:
- [Solved] Query DataTables Error: Cannot reinitialise DataTable
- El Form Verification Error: [XXX] is not a string [How to Solve]
- Bootstrap switch Uncaught TypeError: Cannot read property ‘apply’ of undefined
- [Vue warn]:Error in render: “TypeError: Cannot read property ‘0’ of undefined”
- tf.nn.top_k(input, k, name=None) & tf.nn.in_top_k(predictions, targets, k, name=None)
- JavaScript Uncaught TypeError: Cannot set property ‘innerHTML’ of null”
- [Solved] Vue Error: Error in render: “TypeError: Cannot read property ‘length‘ of undefined“
- Common attributes of unity inspector panel
- [Vue warn]: You may have an infinite update loop in a component render function
- Solve the problem of style in cannot read property ‘style’ of null