How to handle the Errors Display if I use columns directly.
How to handle the Errors Display if I use columns directly.
Omniwyse
Posts: 29Questions: 11Answers: 0
Normally after ajax call we will use Success and Errors as mention below without columns.
success: function(data) {
if("success" === data.status){
d = transform(data);
searchResults.clear();
searchResults.rows.add(data).draw();
}
if("error" === data.status){
deleteCreditCards();
}
},
error : function(data){
}
But now I am using columns With columns suppose from backend I got error how to display them using coumns.I should have the columns and I need to check the status which we got from backend.
"ajax": {
"url": extract_url('/refund/list'),
"data": function ( d ) {
var sortingColumn=d.order[0].column;
var sortingOrder=d.order[0].dir;
d.orderColumn=sortingColumn,
d.order=sortingOrder;
d.search = search,
d.fromDate = fromDate,
d.toDate = toDate,
delete d.columns;
}
},
columns: [
{title: "Activity Id", data: "id",
"render":function(data,type,row,meta){
data = data !=null ? data:notAvailable;
return data;
}},
{title: "Date", data: "dateTime",
"render":function(data,type,row,meta){
data = moment(data).tz(tenantTimeZone).format(displayFormat);
return data;
}}]
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Answers
If I understand the question correctly you are moving from using the jQuery ajax() to the
ajax
option. In theajax
docs there is this statement:Instead of
success
use theajax.dataSrc
or thexhr
event to process this error check:There is also this statement:
This indicates that you can still use the
error
option as it will be passed to jQuery ajax().Kevin