【发布时间】:2019-07-29 04:39:56
【问题描述】:
我想在 Bootstrap 模式中显示表单页面的结果。
一切正常,但不是用表单页面中的数据替换模态正文内容。 我在哪里做错了?当我在警报中显示结果时,它工作正常......
// this is the id of the form
$("#idform").submit(function(e) {
e.preventDefault(); // avoid to execute the actual submit of the form.
var form = $(this);
var url = "form.html"; //form.attr('action');
$.ajax({
type: "POST",
url: url,
data: form.serialize(), // serializes the form's elements.
success: function(data)
{
//alert(data); // show response from the php script. -> Working fine
// Here is (i guess) the problem zone...:
$("#modal-confirmation").modal('show').on("show", function(e) {
$(this).find(".modal-body").load(data);
});
}
});
});
【问题讨论】:
-
事件是“show.bs.modal”而不是“show”:getbootstrap.com/docs/4.0/components/modal
标签: javascript jquery ajax twitter-bootstrap