bootstrap 定时 提示 表单验证 ajax 跳转
$(function () { $(".publish-btn").click(function(){ var data = $("#form").serialize(); var url = "index/insert"; $.ajax({ url: url, type:'post', dataType:'json', data:data, beforeSend: function(){ $('.submit-sure').text('提交中...'); }, success:function(r){ if (r.code == 1) { alert('您已提交成功'); setTimeout( function () { window.location.href= 'index/success'; }, 2000 ); }else { alert('失败'); } } }); return false; }); });
<input type="text" class="form-control" id="tableName" placeholder="请输入表格名称" data-toggle="tooltip" data-placement="top"> <script> function showPopover(target, msg) { target.attr("data-original-title", msg); $('[data-toggle="tooltip"]').tooltip(); target.tooltip('show'); target.focus(); //2秒后消失提示框 var id = setTimeout( function () { target.attr("data-original-title", ""); target.tooltip('hide'); }, 2000 ); } showPopover($("#tableName"),"表名已存在"); </script>