设置ajax完成操作后,过几秒跳转

function countDown(secs){    
			$("#sucAppointment").html("预约成功,"+secs+"秒后返回首页");       
 			if(--secs>0){       
    			 setTimeout("countDown("+secs+")",1000);       
    		 }else{         
		    	 location.href='/p2p';       
		     }       
		 }       

表单提交ajax方法

function addOnlineAppointment(){
			var flag = true;
			if(checkTelphone()&&checkEmail()&&checkAmount()&&checkVerCode()){
				$.ajax({
					url:'${basePath}/p2p/addIOnlineAppointment.html',
					type:'POST',
					data:$("#onlineAppointmentForm").serialize(),
					success:function(data){
						$("#sucAppointment").css("display","inline-block");     
						countDown(5);
					},
					error:function(data){
						alert("似乎遇到了点儿麻烦,请刷新页面重试");
					}
				});
	
			}else{
				flag = false;
			
			}
		}


你可能感兴趣的:(JQuery)