提交Ajax Post时如何刷新模态主体? [英] How to refresh modal body when submit Ajax Post?
本文介绍了提交Ajax Post时如何刷新模态主体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在提交时使用 Bootstrap Modal 提交 ajax 请求,我想刷新模态主体.这意味着我从我的表单中保存的内容,我显示了我的模态主体,我想在表格中显示该行.当我使用这个表时,隐藏了没有刷新任何东西?
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,
});
});
推荐答案
您可以通过将一些新的 html 放入其中来刷新 Modal html,例如:
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
}
这篇关于提交Ajax Post时如何刷新模态主体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文