I'm writing a code that, among other things, needs to intercept the ajax of a datatable and add some data.
So:
$("#table").DataTable{
ajax: {
data: ...
}).MyPlugin();
//In another file: plugin code
$.fn.DataTable.Api.register('MyPlugin()', function (params) {
//something like
$.ajaxPrefilter(function (options) {
var paramsDataTableAjax = $.deparam(options.data);
paramsDataTableAjax["additionalFields"].push({ "Key": DADO_ADICIONAL, "Value": "" });
options.data = $.param(paramsDataTableAjax);
});
//more code ...
});
});
I can not figure out how to do this using the plugin I created (MyPlugin ()).