-1
我有一个登录href链接,切换模式并在iframe中加载页面。成功登录后,模式不会关闭。一直在这里搜索,大部分的答案是添加在线ajax成功关闭bootstrap模式
$('#myModal').modal('hide');
试过,但它没有奏效。我的代码中是否存在任何冲突?
HTML
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="max-width:400px;max-height:400px;width:94%;height:75%;float:right;margin:50px 12px 0 0">
<div class="modal-content" style="position:relative;width:100%;height:100%;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<span style="color:black;font-weight:900;">Login</span>
</div>
<div class="modal-body" style="position:absolute;display:inline-block;width:100%;height:100%;">
<iframe src="login.php" frameborder="0" scrolling="no" allowtransparency="true" style="width:100%;height:90%;"></iframe>
</div>
</div>
</div>
阿贾克斯
$.ajax({
url: url,
type: "post",
data: val,
datatype: 'json',
success: function(data) {
if (data.status == "valid") {
$("input").prop('disabled', true);
$("#login_btn").prop('value', 'Logging in ...');
$('#myModal').modal('hide');
}
else {
$('#msg').html("<font color=red>" +data.message+ "</font>")
}
}
});
你的'data.status'包含了什么?你成功了吗?你到达'if(data.status =='valid')'还是落到'else'? 'FONT'标签已被弃用:http://www.w3schools.com/tags/tag_font.asp – Justinas
可能重复[编程方式关闭ajax成功启动模式](http://stackoverflow.com/questions/36122756/programmatically- close-bootstrap-modal-on-ajax-success) – danielad
data.status来自我的php json数据,它返回状态和消息字符串,我不认为这是问题,因为消息已成功返回。 感谢您的亮点我会修改字体标签:) –