$(function () { $("#form-admin-group-edit").validate({ rules:{ name:{ required:true, minlength: 1, maxlength: 60, remote: { url: pagePath+"/admin/group/isExist", type: "get", data: { name: function () { return $("#name").val(); }, id:$("#id").val() } } }, perms:{ required:true }, remark:{ minlength: 1, maxlength: 200 } }, messages : { name : { remote: "该组名已经存在!" } }, onkeyup:false, focusCleanup:true, focusInvalid:false, success:"valid", submitHandler:function(form){ var userIds=[] $(".add_users tr").each(function(){ userIds.push($(this).find(".user_id").attr("id")); }); $("#userIds").val(userIds); $(form).ajaxSubmit({ type: 'POST', url: pagePath+"/admin/group/updateGroup", dataType:"json", success: function(data){ if (data.success) { succeedMessage(data.message); setTimeClose(); }else { errorMessage(data.message); } } }); return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。 } }); }); /*选择用户*/ function select_user(title, url, w, h) { layer_show(title, pagePath+url, w, h); } function addUsers(userLists){ var userIds=[]; $(".no_data").remove(); var html=""; $(".add_users tr").each(function(){ userIds.push($(this).find(".user_id").attr("id")); }); debugger; $.each(userLists, function(index, obj) { if(!array_contain(userIds,obj.id)){ html+="