如何在无需点击按钮的情况下打开 bootstrap 弹窗?
如何在无需点击按钮的情况下打开 bootstrap 弹窗?
这个问题已经有了答案:
我需要在我页面ajax的成功函数中弹出一个Bootstrap模态窗口。当表单提交时,成功函数会被调用。那么有没有什么方法可以在没有按按钮的情况下弹出Bootstrap模态窗口呢?我是一名新手,请在这里帮帮我。
这是我的ajax调用...
$("#form").submit(function(e) { $.ajaxSetup({ headers:{'X-CSRF-Token' : $('meta[name=_token]').attr('content')} }); e.preventDefault(); //STOP default action var postData = $(this).serializeArray(); console.log(postData); var formURL = "http://localhost:8000/v1/people_roles"; $.ajax( { url :formURL , type: "POST", data : postData, success:function(response, textStatus, jqXHR) { if(response.parent==1) { $("#getCode").html(response); $("#getCodeModal").modal('show'); window.location.href="/web/staff/detail.php?id="+response.people_id; } else { //console.log(response); window.location.href="/web/staff/detail.php?id="+response.people_id; } } }); });
这是我的html模态代码...
Modal title
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
admin 更改状态以发布 2023年5月24日