Refresh DataTable after ajax call
Refresh DataTable after ajax call
OnLog
Posts: 12Questions: 4Answers: 1
Hi, I have a right click function with ajax call to server. I would like the table to refresh after this call but I get "Invalid JSON".
Here is the function:
//get right-click menu
$(function () {
var MenuItems = [];
MenuItems = ContextMenuItems();
$('#dynamicTablePlain').contextMenu({
selector: 'tr',
trigger: 'right',
build: function ($trigger, e) {
var options = {
callback: function (key, options) {
var column0 = new Array();
var selectedRows = table.cells('.selected', 0).data();
for (var i = 0; i < selectedRows.length; i++) {
column0.push(selectedRows[i]);
}
var items = MenuItems;
var actionSP = items[key]._contextItemAction;
var ResponseSuccessText = items[key]._responseSuccessText;
var ResponseErrorText = items[key]._responseErrorText;
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'json',
type: 'POST',
url: '/api/contextItemAction/post/' + actionSP,
data: JSON.stringify(column0),
success: function (response) {
if (response.success) {
alert(ResponseSuccessText);
--------------------------------------> here is where I would like to refresh <----------------------------------------------------------
} else {
alert(ResponseErrorText);
}
},
})
},
// start with an empty map
items: {}
};
$.each(MenuItems, function (k, v) {
options.items[k] = { name: v._contextItemName, icon: v._icon };
});
return options;
}
});
});
This discussion has been closed.
Answers
What is the server returning if it isn't valid JSON?
Allan