My problem is when i click the button to show the data from database to html table it shows up but when i try to click the button again it duplicates the content of the table and it continues to duplicate as long as i click the button.
script:
$('#showData').click(function() {
$.ajax({
url: 'Oppa/view/file.php',
type: 'post',
data: {tag: 'getData', code: $('#emailCodeResult').val()},
dataType: 'json',
success: function(data) {
if (data.success) {
$.each(data, function(index, record) {
if ($.isNumeric(index)) {
var row = $("<tr />");
row.appendTo("#myTable2 tbody");
}
})
}
$('#myTable2').dataTable({
"bjQueryUI": true,
"bFilter": false,
"bRetrieve": true,
"sPaginationType": "full_numbers",
"bAutoWidth": true,
"bPaginate": false,
"bInfo": false,
"bLengthChange": false
});
}
});
});