0

hello i am building a project with laravel, where i am passing the multiple data from CategoryController to Category blade file, but the problem is when i am inserting data it is successfully inserted and i want to reload the datatable with the new record but my existing table of id example1 is going inside of another table of id example1 why? Here are my codes...

script

$("#example1").DataTable();

$(document).on('submit','.database_operation',function(e){
    e.preventDefault();
    var url = $(this).attr('action');
    var data = $(this).serialize();
    $.ajax({
        url:url,
        method:"POST",
        data:data,
        success:function(fb){
            var resp = $.parseJSON(fb);
            // console.log(resp);
            if(resp.status=='true'){
                toastr.success(resp.message,'Success');
                $('#myModal').hide();
                $('.modal-backdrop').remove()
                $(document.body).removeClass("modal-open");
                $('#example1').DataTable().clear().destroy();
                $("#example1").DataTable();
                $("#example1").load(" #example1");
            }else if(resp.status=='false'){
                    
                $.each( resp.message, function( key , value ) {
                toastr.error(value + '<br>','Error');
                });
                

            }else if(resp.status=='false-1'){
                toastr.error(resp.message,'Error');
            }
            
            
        }

    });
    
    return false;
});

Hey i am beginner with laravel and jquery trying to learn please help me with the best possible way.

1 Answer 1

1

Try add $('#example1').DataTable().ajax.reload(); after resp status is true.

Read realated problem here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.