var Ispost=false ;
$(document).ready( function (){
packPost("no");}
);
function packPost(action) { if(Ispost) return ; Ispost =!Ispost; $.post("Ajax/Dates.ashx?type="+action,$("#form1").serialize(), function(data){ Ispost=!Ispost;//恢复异步提交状态 if(data!="") {
var obj = eval(data); // 数据转化为数组; data格式为:[{a:"a",b:"b",v:"v" }] 等等
...}
}
}
ashx 接受方:
string action=context .Request .QueryString ["type"];
//这种要传入窗体的form id
context.Request.Form["txtLoginName"].ToString();
时间倒计时:
var time=15; //5分钟活动 var endtime=300; var s='url'; var remark='活动已结束!敬请期待!'; var duration= 20*60; var imgurl="img/url; var url="";
if(time>0) { } else { if(time+duration>0) {endtime =time+duration;time=-1;} else { time=-1;endtime =-1;} } countStart(time,function( msg ) { $("#timer3").html(msg); });
//时间 结束操作 function countStart( maxtime,fn ) { var timer = setInterval(function(){ if(maxtime>=0) { d=parseInt(maxtime/3600/24%365); h=parseInt((maxtime/3600)%24); minutes=parseInt((maxtime/60)%60); seconds=parseInt(maxtime%60); msg = "距离活动开始还有n"+d+"天"+h+"小时"+minutes+"分"+seconds+"秒"; fn(msg); //$("#img").removeClass("isuper button pink"); // $("#img").removeClass("isuper button blue"); // $("#img").addClass("isuper button green"); // if(maxtime== 3*60) // alert('注意,还有3分钟开始秒杀活动!'); --maxtime; } else{ clearInterval( timer ); countDown(endtime,function( msg ) { $("#timer3").html(msg); }); } },1000); } //时间 结束操作 function countDown( maxtime,fn ) { var timer = setInterval(function(){ if(maxtime>=0) { // $("#img").removeClass("isuper button green"); // $("#img").removeClass("isuper button blue"); // $("#img").addClass("isuper button pink"); // $("#img").click(function (){ window.location .href=s;}); d=parseInt(maxtime/3600/24%365); h=parseInt((maxtime/3600)%24); minutes=parseInt((maxtime/60)%60); seconds=parseInt(maxtime%60); msg = "距离活动结束还有"+d+"天"+h+"小时"+minutes+"分"+seconds+"秒"; fn( msg ); // if(maxtime== 3*60) // alert('注意,还有3分钟活动结束!'); --maxtime; } else { clearInterval( timer ); // $("#img").removeClass("isuper button pink"); // $("#img").removeClass("isuper button green"); // $("#img").addClass("isuper button blue"); //$("#timer3").css("color","#555555");//灰色 fn(remark); } },1000); }
html:
<div id="timer3" style="color: #616161; font-family: 黑体; font-size: 16px;"> </div> (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|