I have my dataTable script below working and bringing data very well, but i want to perform some tasks. like when i click the button the post call for ajax get executed
my problem is that when i click the Button
$('td:eq(1)', row).html('<button type="button" id="showup"> Submit </button>');
nothing happens its like not normal, not picking any event. its not working to do the post call for ajax
my datatable output is like this
<tr>
<td><input type="text" name="Country" value='Italy' /></td>
<td><button type="button" class="showup"> Submit </button></td>
</tr>
<tr>
<td><input type="text" name="Country" value='Spain' /></td>
<td><button type="button" class="showup"> Submit </button></td>
</tr>
Now i want when i press the button to do a post call to send the value of the actual input name=“Country” in tr
$(document).ready(function() {
$('.showup').on('click', function() {
execute($(event.target).prev("input"));
$(this).html("Clicked");
$(this).attr("disabled", true);
function execute($input) {
$.ajax({
type: "POST",
url: "file2.php",
data: {
Country: $input.val(),
},
success: function(response) {},
error: function() {
alert("Error");
},
});
}
});
var table = $("#information").dataTable({
"pagingType": "simple",
"stripeClasses": [],
"bLengthChange": false,
sDom: "ltipr",
oLanguage: {
sEmptyTable: '',
sProcessing: '',
oPaginate: {
sNext: 'Next',
sPrevious: 'Previous',
},
},
responsive: {
details: {
display: $.fn.dataTable.Responsive.display.modal({}),
renderer: $.fn.dataTable.Responsive.renderer.tableAll({
tableClass: "table",
}),
},
},
"processing": true,
"ajax": {
"url": "file.php",
"type": "GET",
"dataType": "json"
},
rowCallback: function(row, data) {
$('td:eq(0)', row).html('<input type="text" name="Country" value=' + data[0] + ' />');
$('td:eq(1)', row).html('<button type="button" id="showup"> Submit </button>');
},
});
});