Introduction: I am doing a server-side datatables library using PHP and Ajax. When a user clicks the edit button I want to transfer that id to PHP so I can later update it...
I am basically doing these two stack-overflow articles combined:
Index.php
<script type="text/javascript">
$(document).on('click','.edit_btn',function (){
var edit_id = $(this).attr("id");
alert(edit_id);
$.ajax({
url: 'index.php',
data: { edit_id : edit_id },
contentType: 'application/json; charset=utf-8',
success: function(result) {
alert(result);
}
});
});
</script>
Edit button code:
columnDefs:
[
{
targets: -1,
render: function (data, type, row, meta) {
return '<input type="button" class="delete_btn" id=n-"' + meta.row + '" value="delete"/> <input type="button" class="edit_btn" id=s-"' + meta.row + '" value="edit" name="edit_btn"> </a>';
}
}
]
I believe datatables library does not recommend using the get method from the URL. What am I missing? Thanks.