4、jquery--ajax/json

template:
function saveUser() {
    //validate
    var form1 = $("#insertUser").form('validate');
    if (!form1) return;
   
    var user = {
        type: UserObj.type,
        oid:UserObj.oid,
        name:$("#uname").val(),
        pwd:  $("#pwd").val(),
        dept:  $("#dept").val()
    };
    $.ajax({
        type: "post",
        url: "../Ajax/skxdmo1.ashx",
        data: user,
        success: function (data) {
            if (data == "0") {
                alert("保存成功");
                UserObj.type = 1;
                $('#dlg').dialog('close');      // close the dialog 
                $('#effusers').datagrid('reload');    // reload the user data
            }
            else if (data == "1") {
                UserObj.type = 1;
                alert("数据库异常");
            } else if (data == "2") {
                alert("登录名重复");
            }
        }
    });
   
}

你可能感兴趣的:(jquery)