Ajax DataTables with jQuery

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Jan 31, 2018 1:27 am

Wed Jan 31, 2018 1:32 am

I am trying to load a table with a button at the end of each row with DataTables but after clicking the button, it only gives me undefined values. Please help. :help: :help:

<script type="text/javascript">
$(document).ready(function () {
"columns": [
{"data": "EMPNUMBER"},
{"data": "EMPNAME"},
{"data": "DESIGNATION"},
{"data": "PF_INDEX"},
{"data": "EMP_DOB"},
"className": 'options',
"data": null,
"render": function(data, type, full, meta){

if (full.activated) {
return '<button> Enabled</button>';
} else {
return '<button> Disabled</button>';
"processing": true,
"serverSide": true,
"ajax": {
url: 'demo2.php',
type: 'POST'
var table = $('#users3').DataTable();
$('#users3').on( 'click', 'button', function () {
var data = table.row( $(this).parents('tr') ).data();
alert( data[0] +"'s salary is: "+ data[1] );
} );
error.png (4.91 KiB) Viewed 555 times

Post Reply