ajax 提交

时间:2016/10/14 14:45:00来源:互联网 作者:flyso 点击: 2529 次

前端部分:

    $.ajax({

        type: 'post',

        url: 'ajax/flyso.aspx?action=do',

        data: $(".flysoForm").serialize(),

        success: function (data) {

            if (data == 1) {

                succ("留言成功!");

                $(".lxform")[0].reset();

            }

            else if (data == 3)

                warn("一小时内只允许提交3次!");

            else

                alert("留言失败!");

        }

    });

后端部分:

Hashtable ht = Requests.GetAllValues();

ht["ip"] = Client.IPAddress;

if (TSQL.LookUpInt("select count(1) from t_flyso where ip='" + ht["ip"] + "' and datediff(hour,addtime,getdate())=0") >= 3)

{

    Response.Write("3");

    return;

}

int i = TSQL.Insert("t_flyso", ht);    //新增

if (i > 0)

{

    Response.Write("1");

}

else

    Response.Write("2");


Copyright © 2005 - 2016 flyso.cn. 飞搜 版权所有 鄂ICP备11002783号-3