Javascript 如何在ajax成功中打开引导模式
我想通过jquery打开引导模式。我知道ajax在成功运行时会发出警报。但无法打开模式。这是我的密码Javascript 如何在ajax成功中打开引导模式,javascript,jquery,css,ajax,twitter-bootstrap,Javascript,Jquery,Css,Ajax,Twitter Bootstrap,我想通过jquery打开引导模式。我知道ajax在成功运行时会发出警报。但无法打开模式。这是我的密码 $.ajax({ type: "POST", url: "<?php echo base_url() . 'index.php/application/requestCode'; ?>", data: { 'apiName': apiName, 'api': api, 'hotel': hotel,
$.ajax({
type: "POST",
url: "<?php echo base_url() . 'index.php/application/requestCode'; ?>",
data: {
'apiName': apiName,
'api': api,
'hotel': hotel,
'payment':payment,
'template': template
},
success: function(msg)
{
$("#getCodeModal").modal("toggle");
$("#getCode").html(msg);
}
});
$.ajax({
类型:“POST”,
url:“”,
数据:{
“apiName”:apiName,
“api”:api,
“酒店”:酒店,
“付款”:付款,
“模板”:模板
},
成功:功能(msg)
{
$(“#getCodeModal”).modal(“切换”);
$(“#getCode”).html(msg);
}
});
我的模式HTML是:
<!-- Modal -->
<div class="modal fade" id="getCodeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel"> API CODE </h4>
</div>
<div class="modal-body" id="getCode" style="overflow-x: scroll;">
//ajax success content here.
</div>
</div>
</div>
</div>
&时代;
API代码
//这里是ajax成功的内容。
控制台中出现错误:模式不是一个函数。请尝试使用此功能
success: function(resp){
$("#getCode").html(resp);
$("#getCodeModal").modal('show');
}
试试这个:
success: function(data) {
$("#getCode").html(data);
jQuery("#getCodeModal").modal('show');
}
这应该有效:)。当您两次包含库jquery时,就会发生这种情况。检查一下,也许你把它包括在你的索引中,然后再不必要地放在你的部分页面中。写下下面的代码。
发生了什么?控制台中出现一些错误?请尝试将左括号与
success:function(msg)
放在一行中。是否导入了bootstrap.js
?是。当然是我进口的。它通过数据属性显示。我解决了错误。jquery库是在bootstrap.js之后导入的。仅$(“#getcodemodel”).modal('show')代码>在成功函数中是必需的@Shakil在put$(“#getCode”).html(resp)时不显示模型中的任何内容这也是我一直在寻找的正确答案。谢谢。从上面抄过来的
success: function(msg)
{
$("#getCodeModal").modal("show");
$("#getCode").html(msg).show();
}