Hi
I have below code in Js file. I want when User Update record , datatable should get refreshed.
- function Update() {
- var res = validate();
- if (res == false) {
- return false;
- }
- var objLocation = {
- Id: $('#txtId').val().toUpperCase(),
- Description: $('#txtDescription').val().toUpperCase()
- };
- $.ajax({
- url: "/Home/Update",
- data: JSON.stringify(objLocation),
- type: "POST",
- contentType: "application/json;charset=utf-8",
- dataType: "json",
- success: function (result) {
- $('#myModal').modal('hide');
- clearTextBox();
- },
- error: function (errormessage) {
- alert(errormessage.responseText);
- }
- });
- }
- ****************************************************
- $(document).ready(function () {
- $("#tblLocation").dataTable({
- ajax: {
- type: "get",
- url: "/Location/List",
- dataType: "json",
- dataSrc: ""
- },
- paging: true,
- sort: true,
- pageLength: 5,
- searching: true,
- columns: [
- { 'data': 'Id' },
- { 'data': 'Description' },
- {
- "defaultContent": '<input type="button" id="btnEdit" class="btn btn-primary" value="Edit" />'
- }
- ]
- });
- $('body').on('click', '[id*=btnEdit]', function () {
- var data = $(this).parents('tr').find('td');
- var id = data.eq(0).html();
- var description = data.eq(1).html();
- $('[id*=txtId]').val(id);
- $('[id*=txtDescription]').val(description);
- $('#myModal').modal("show");
- });
- });
Thanks