3
Answers

search and sorting not working

Ashish Pandey

Ashish Pandey

6y
472
1
$.ajax({
url: '@Url.Action("Getcountry", "Master")',
type: 'GET',
contentType: 'application/json; charset=utf-8',
dataType: 'JSON',
data: { data: "" },
cache: false,
success: function (data) {
result = (data);
if (result.length > 0) {
// to remove old record
$('#myDatatable tbody tr').remove();
for (var i = 0; i < result.length; i++) {
tr = "<tr>";
tr += "<td>" + (i + 1) + "</td>";
tr += "<td>" + result[i].CountryName + "</td>";
tr += "<td>" + result[i].VCountryCode + "</td>";
tr += "<td>" + result[i].TimeZoneText + "</td>";
tr += "<td><button class='btn btn-primary' onclick='Edit(" + result[i].CountryCode + ");'><i class='glyphicon glyphicon-edit'></i> Edit</button>";
tr += "&nbsp;<button class='btn btn-danger' onclick='Delete(" + result[i].CountryCode + ");'><i class='glyphicon glyphicon-trash'></i> Delete</button></td></tr>";
$('#myDatatable').append(tr);
}
}
},
failure: function (data) {
alert('Failure!');
},
error: function (data) {
alert('Error!');
}
});
search and sorting not working
Answers (3)