javascript - Reload page js after database query in MVC -


i have such script:

$(document).ready(function () {     $('#requesttable').datatable(         {             aocolumns: [             { mdataprop: "datestart", stitle: "date start" },             { mdataprop: "dateend", stitle: "date end" },             { mdataprop: "approved", stitle: "approved" },             { mdataprop: "data", stitle: "employee" },             { mdataprop: "position", stitle: "position" },             { mdataprop: "", stitle: "" }             ],             columndefs: [{                 targets: 'no-sort',                 orderable: false             }]         });      $('button.accept-button').click(function () {         var id = $(this).attr('data-id')                 $.ajax({             type: "post",             url: "/tablerequest/acceptrequest",             data: { 'id': id },             success: function (msg) {             }         });         location.reload(true);     });     var tempid;     $('button.decline-button').click(function () {         tempid = $(this).attr('data-id')         $("#dialog").dialog()     });     $('button.ok-request').click(function () {         var message = $('textarea#commentfordecline').val();          $.ajax({             type: "post",             url: "/tablerequest/declinerequest",             data: { 'message': message, 'id': tempid },             success: function (msg) {             }         });         $("#dialog").dialog('close');         $('textarea#commentfordecline').val('');         location.reload(true);     }); });  

as can see reload page after post ajax query. there way check changes in db , refresh page after (call action)? db changes late , wanna check it.

you can reload page after success, , backend action return data want check , after can reload

success: function (data) {     console.log(data);     if (data.somekey === "somevalue"){         location.reload(true);     } else {         //don't reload show me erros     }  } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -