问题
Im submitting ajax request using Bootstrap Modal when i submit i want refresh modal body. it means what i have saved from my form im showing my modal body i want show that row in table. when i use this that table got hide not refreshing anything rong ?
$('#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").replaceWith($('#images-table', $(data)));
$("#some_form")[0].reset();
},
error:function (data) {
alert('error');
},
async:false,
processData: false,
contentType: false,
});
});
回答1:
You can simply refresh the Modal html by putting some new html into it like:
success:function(data){
// here data contains the response for your ajax call
var newHTML = data;
$("#images-table").html(newHTML); // This will put new html and remove old
}
来源:https://stackoverflow.com/questions/42051048/how-to-refresh-modal-body-when-submit-ajax-post