我有一些jQuery代码在数据库中插入记录。我需要在一段时间内重新加载页面。这意味着,当我点击提交按钮时,成功消息或错误消息将首先显示,然后页面将在5秒后重新加载。刷新一段时间的页面
我的代码:
(function($){
$(document).ready(function(){
$("#submit").click(function(){
//alert("testing2.....")
var num = /^[0-9]/;
var date=$("#date").val();//alert(date);
var sMan=$("#sMan").val();//alert(pType);
var cName=$("#cName").val();
var input_type=$("#input_type").val();
var tamt=$("#tamt").val();
var tpaid=$("#tpaid").val();
//use the $.post() method to call insert.php file.. this is the ajax request
$.post('action/b_payment.php', {
date: date,
sMan: sMan,
cName: cName,
input_type: input_type,
tamt: tamt,
tpaid :tpaid
},
function(data){
$("#message").html(data);
$("#submit").attr('disabled','disabled');
$("#message").hide();
$("#message").fadeIn(1500); //Fade in the data given by the insert.php file
$('#formId').each(function(){ //This code is for reload the page
window.location.reload(true);
});
});
return false;
});
});
})(jQuery);
我怎么能显示时间5秒后的消息?
使用的setTimeout(函数(){window.location.reload(真);},5000); – 2013-04-28 08:08:51
其工作,谢谢... – 2013-04-28 09:48:56