event target doesn't get updated on ajax.reload()
event target doesn't get updated on ajax.reload()
Hello,
Could someone help me figure it out...
I have html form with multiple submit buttons. Depending on which button I click I want different action.
I also use some values from form. It's get populated by $.each.
I am also adding which button I have clicked with d[event.target.name] = event.target.value;
It works FIRST time, but when I click second time and do ajax.reload() - event.target.name and value is used the one which i clicked first when I created datatable. Any help?
"ajax": {
"type": 'POST',
"url": '/Search/?json=true',
"data": function (d) {
$.each($('#searchForm').serializeArray(), function () {
d[this.name] = this.value || '';
});
console.log('e:' + JSON.stringify(event.target.name));
d[event.target.name] = event.target.value;
}
}
Answers
Have you tried
ajax.reload()
?https://datatables.net/reference/api/ajax.reload()