After ajax call to delete, how to append data from database
I have a MVC application that has a timer that deletes a name every 15 seconds from the table and the database. I have the deletion working correctly. However, I am stuck on figuring out how to always have 5 records displaying. I have tried to reload the table but that isn't working either.
For example, I have records 1,2,3,4,5, when record 1 is deleted when the timer reaches the end of 15 seconds, then the page should display 2,3,4,5,6. (If I Need to display my MVC code i can add that.)
- $(document).ready(function () {
- startTimer();
- function startTimer() {
- $('#timer').countdown({
- layout: '{mnn} : {snn}', timeSeparator: ':', until: 15, onTick: TimerColorChange, onExpiry: restartTimer
- });
- }
-
-
- function restartTimer() {
-
- var Id = $("#item_Id").val();
- $('#timer').countdown('destroy');
-
- //we delete the table's Info
- $('#FullName').parent().remove();
-
- // deleting records from entity framweork database;
- $.ajax({
- url: '@Url.Action("Delete", "UserNames")',
- type: "POST",
- data: ({ Id: Id }),
- dataType: "json",
- cache: false,
- async: true,
- success: function (data) {
- $('#NameList > tbody:last-child').append("<tr><td>"+ $('#FullName').val()+"</td> </tr>");
- // $('#NameList').html(data);
- }
- });
-
- startTimer();
- }