ajax读写cookie的问题
JS部份
var searchcount="0";
var ssql="action=getsarchcount"
$.ajax({
type: "get",
async : false,
dataType: "html",
url: '/inc/act.asp',
data: ssql,
success: function (data) {
searchcount=data;
}
});
//alert(searchcount);//注意这句
//return false;
var sql="action=searchorder&key="+key+"&code="+code
$.ajax({
type: "get",
async : false,
dataType: "json",
url: '/inc/act.asp',
data: sql,
success: function (json) {
alert(json.msg);
}
});
If act="getsarchcount" Then'获取查询次数
dim sercharNum
sercharNum=Request.cookies("SearchCount")
if sercharNum="" Then sercharNum=0
Response.Write(sercharNum):Response.End()
ElseIf act="searchorder" Then'查询受理状态
orderid=Request.QueryString("key")
if orderid="" Then ShowJson "0","受理号不能为空"
'验证码判断
sercharNum=Request.cookies("SearchCount")
if sercharNum="" Then sercharNum=0
if Cint(sercharNum)>3 Then
code=Request.QueryString("code")
if code="" Then ShowJson "0","请输入验证码"
if code<>session("GetCode") Then ShowJson "0","验证码错误,请重新输入或获取"
End If
Response.Cookies("yhSearchCount").Expires=Date+7 '指定cookie保存时间
Response.Cookies("yhSearchCount")=cint(sercharNum)+1
Set Rs=Conn.execute("select * from tablename")
if Rs.eof and Rs.Bof Then
ShowJson "1","记录不存在"
Else
Response.Write("{""type"":""2"",""appdate"":"""&Rs("addtime")&"""""}")
Response.End()
End If
End If