page refresh after ajax request

page refresh after ajax request

volnistii11volnistii11 Posts: 49Questions: 16Answers: 0
edited October 2020 in Free community support

Hello, please tell me how to update the page after an ajax request?

     editor = new $.fn.dataTable.Editor( {
    ajax: {
    "url" : "new.php",
    },
    table: "#empTable",
    idSrc:  'id',
             }

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,304Questions: 26Answers: 4,947

    The server needs to follow the Cleint/Server protocol by returning the row data as descried in the example data exchanges section.

    Kevin

  • volnistii11volnistii11 Posts: 49Questions: 16Answers: 0

    I understand, but maybe is there a possibility?

  • volnistii11volnistii11 Posts: 49Questions: 16Answers: 0

    Something like: if the request succeeds, then reload, etc.

  • kthorngrenkthorngren Posts: 21,304Questions: 26Answers: 4,947

    Oh, I understand now. You can use the submitSuccess event. An example is shown in this blog.

    Kevin

  • volnistii11volnistii11 Posts: 49Questions: 16Answers: 0

    Could you explain how it will look like in my example, or something I can't figure out?

      var table = $('#empTable').DataTable({
    
      'processing': true,
      'serverSide': true,
      "lengthMenu": [[10, 25, 50, 1000000000], [10, 25, 50, "All"]],
      "pageLength": 25,
        dom: 'lBrtip',
        buttons: [
            'excelHtml5',   
        ],
        select: true,
    
      'serverMethod': 'post',
      'ajax': {
            url:'back_2.php',
    
      },
      })
    
  • kthorngrenkthorngren Posts: 21,304Questions: 26Answers: 4,947
    Answer ✓

    To use submitSuccess with your editor to reload your table use something like this:

    editor.on( 'submitSuccess', function () {
        table.ajax.reload();
    } );
    

    Kevin

  • volnistii11volnistii11 Posts: 49Questions: 16Answers: 0

    If someone has a similar problem, then this helped me:

    var editor;
    $(document).ready(function() {
    
          editor = new $.fn.dataTable.Editor( {
          .
          .
          .
          } );
    
     table = new $('#empTable').DataTable({
     .
         .
         .  
         });
    
         editor.on( 'submitSuccess', function () {
        table.ajax.reload();
        } );
    
      });
    
This discussion has been closed.