繁体   English   中英

Bootstrap可拒绝的成功消息不再与Ajax一起显示

[英]Bootstrap dismissable success message not showing longer with ajax

我有一个ajax窗体,该窗体使用PHP post方法获取数据。 我没有使用Javascript的警报功能,而是调用了引导成功消息。 但问题是它不会显示持续时间仅少于一秒。 如何显示它的长度,直到用户手动将其关闭为止。

编码部分:

 function send_form() { $.ajax({ url: "./admin-security.php", type: "POST", data: { ip: $("#ip").val() }, success: function(response) { if(response==1) { $("#ajax-ip-success").show(); location.href = "./admin-security.php"; } else alert("Fail! DataBase Error"); } }); } 
 <?php //--AJAX PART CALLING if(isset($_POST['ip'])){ if($IP = filter_input(INPUT_POST, 'ip', FILTER_SANITIZE_STRING)){ $add_ip = $mysqli->prepare("INSERT INTO block_ip(b_ip) VALUES(?)"); $add_ip->bind_param("s",$IP); $add_ip->execute(); $add_ip->store_result(); $add_ip->close(); echo 1; } else { echo 0; } exit; } ?> <div class="alert alert-success alert-dismissable fade in" style="display: none;" id="ajax-ip-success"> <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> <strong>Success!</strong> IP added successfully. </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="ip"> Enter IP:</label> <div class="col-sm-8"> <input type="text" name="ip" class="form-control" id="ip" /> </div></div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-8"> <button type="button" onClick="send_form()" class="btn btn-default" >Submit</button> </div></div> </div> 

您可以为位置重定向设置超时

setTimeout(function(){
 location.href = "./admin-security.php"; 
},2000); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM