jquery 通用的表单(form)提交 input 不指定

Else , 2009/10/27 13:05 , JQuery资源 , Comments(0) , Reads(1113) , Via Original
加一個省事的回調
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* www.sofut.com mysite
* www.aixq.com blog
*/
function ajaxsend(actset,inputid,showmsg)
{
    $.ajax({
        beforeSend:function(){
            $("#msg").html("正在建立链接..");
        },
        dataType:"json",
        type: "post",
        url:"ajax.php?act="+actset,
        data: $("#"+inputid+" :input").serialize(),
        success: function(json){
          
            if(json.msg)
            {
                if(showmsg)
                {
                    alert(json.msg);
                }
                $("input[type=reset]").click();
                $("#msg").html(json.msg);
                if($("#loadbody").text()!="")
                {
                    $("#loadbody").load(window.location.href+"?"+Math.random()+" #loadbody",function(){});
                }
            }
            else
            {
                alert(json.error);
                $("#msg").html(json.error);
                  

            }
          
        },
        error:function(){
            $("#msg").html("链接出错");
        }
    });
}




function ajaxsend(actset,inputid,showmsg)
{
    $.ajax({
            beforeSend:function(){
                $("#msg").html("正在发送");
            },
            dataType:"json",
            type: "post",
            url:"ajax.php?act="+actset,
            data: $("#"+inputid+" :input").serialize(),
            success: function(json){
                if(showmsg)
                    {
                        alert(json.msg);
                    }
            },
            error:function(){
                $("#msg").html("链接出错");
            }
        });
}


详细一点的


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* www.sofut.com mysite
* www.aixq.com blog
*/
function ajaxsend(actset,inputid,showmsg)
{
    $.ajax({
        beforeSend:function(){
            $("#msg").html("正在发送");
        },
        dataType:"json",
        type: "post",
        url:"ajax.php?act="+actset,
        data: $("#"+inputid+" :input").serialize(),
        success: function(json){
            if(showmsg)
            {
                if(json.msg)
                {
                   alert(json.msg);
                   $("#msg").html(json.msg);
                    $("input[type=reset]").click();
                }
                else
                {
                    alert(json.error);

                }
            }else
            {
                   $("#msg").html(json.msg);
            }
        },
        error:function(){
            $("#msg").html("链接出错");
        }
    });
}


Tags: ,
Add a comment

Nickname

Site URI

Email

Enable HTML Enable UBB Enable Emots Hidden Remember [Login] [Register]