简体   繁体   中英

How to refresh table data ajax form submit?

I'm submitting an ajax request using Bootstrap Modal. When I submit, I want to refresh the modal body. It means that what I have saved from my form I'm showing my modal body I want show that row in table. when I use this, that table got hidden without refreshing. What's wrong?

$('#uploadform').submit(function(e) {

    e.preventDefault();

    var formData = new FormData();
    formData.append('file', $('input[type=file]')[0].files[0]);
    formData.append('task_id','{{$task->id}}');
    formData.append('title',$('#title').val());

    $.ajax({
        type:'POST',
        url:'{{url('/uploadTask')}}',
        data:formData,
        success:function(data){

            $("#images-table").html(data);

            $("#some_form")[0].reset();

        },
        error:function (data) {
            alert('error');
        },
        async:false,
        processData: false,
        contentType: false,
    });
});

return that row data form controller and create html and append to to existing table. there is no concept of refreshing bootstrap table. only append new data.

$('#tableid').append('<tr><td>name</td><td></td></tr>');

this will append that row to at the last of your table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM