提示框內容如下
DataTables warning: table id=dataTable - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
查看一下源碼我們能夠看到
var baseAjax = {
"data": data,
"success": function (json) {
var error = json.error || json.sError;
if ( error ) {
_fnLog( oSettings, 0, error );
}
oSettings.json = json;
callback( json );
},
"dataType": "json",
"cache": false,
"type": oSettings.sServerMethod,
"error": function (xhr, error, thrown) {
var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
if ( $.inArray( true, ret ) === -1 ) {
if ( error == "parsererror" ) {
_fnLog( oSettings, 0, 'Invalid JSON response', 1 );
}
else if ( xhr.readyState === 4 ) {
_fnLog( oSettings, 0, 'Ajax error', 7 );
}
}
_fnProcessingDisplay( oSettings, false );
}
};
這時datatables的源碼,我們可以看到是應爲error的那個_fnLog打印出來的,所以只需要覆蓋掉error就可以,當然這只是一種方法,還有很多方法可以屏蔽掉
"ajax": {
"url": "/list",
"type": "POST",
"error": function (xhr, error, thrown){
console.error(error);
}
}
我是這麼簡單的改的