这个问题在这里已经有答案了:
如何使用jQuery打开引导模式窗口?
(16个答案)
(16个答案)
五年前关闭的
我需要在我的页面中的ajax成功函数中弹出一个引导模式。提交表单时会调用成功函数..,那么有没有方法不用点击按钮就弹出引导模式。我是新手..,请在这里帮助我。。
这是我的ajax调用
$(“#表单”)。提交(函数(e)
{
$.ajaxSetup({
标题:{'X-CSRF-Token':$('meta[name=_Token]')。attr('content')}
});
e、 preventDefault();//停止默认操作
var postData=$(this.serializeArray();
console.log(postData);
var formURL=”http://localhost:8000/v1/people_roles";
$.ajax(
{
url:formURL,
类型:“POST”,
数据:postData,
成功:函数(响应、文本状态、jqXHR)
{
if(response.parent==1)
{
$(“#getCode”).html(响应);
$(“#getCodeModal”).modal('show');
window.location.href=”https://stackoverflow.com/web/staff/detail.php?id=“+response.people\u id;
}
其他的
{
//控制台日志(响应);
window.location.href=”https://stackoverflow.com/web/staff/detail.php?id=“+response.people\u id;
}
}
});
});
这是我的html模式代码
<;div class=“modal fade”id=“getcodemodel”tabindex=“-1”role=“dialog”aria labelledby=“myModalLabel”aria hidden=“true”>;
<;div class=“模态对话框模态lg”>;
<;div class=“模态内容”>;
<;div class=“模态标题”>;
<;h4 class=“模态标题”>;情态标题</h4>;
</部门>;
<;div class=“模态体”>;
<;p>&书信电报;strong>;Lorem Ipsum只是个傀儡</strong>;印刷和排版行业的文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一个未知的
印刷工拿起一个铅字厨房,把它翻成一本铅字样本书。它不仅存活了五个世纪,而且还跨越了电子排版,
基本上保持不变/p>;
</部门>;
<;div class=“模态页脚”>;
<;button type=“button”class=“btn btn white”ng click=“cancel()”>;关闭</按钮>;
<;button type=“button”class=“btn btn primary”ng click=“ok()”>;保存更改</按钮>;
</部门>;
</部门>;
</部门>;
</部门>;
$(“#getCodeModal”).modal('show')
有关更多信息,请参阅此文档:
如何使用jQuery打开引导模式窗口