//=====================初始化代码====================== $(function () { //初始化验证表单 $("#regform").validform({ tiptype:3, callback:function(form){ //ajax提交表单 $(form).ajaxsubmit({ beforesubmit: showrequest, success: showresponse, error: showerror, url: $("#regform").attr("url"), type: "post", datatype: "json", timeout: 60000 }); return false; } }); //表单提交前 function showrequest(formdata, jqform, options) { $("#btnsubmit").val("正在提交...") $("#btnsubmit").prop("disabled", true); $("#chkagree").prop("disabled", true); } //表单提交后 function showresponse(data, textstatus) { if (data.status == 1) { //成功 var d = dialog({content:data.msg}).show(); settimeout(function () { d.close().remove(); location.reload(); //location.href = data.url; }, 2000); } else { //失败 dialog({title:'提示', content:data.msg, okvalue:'确定', ok:function (){}}).showmodal(); $("#btnsubmit").val("再次提交"); $("#btnsubmit").prop("disabled", false); $("#chkagree").prop("disabled", false); } } //表单提交出错 function showerror(xmlhttprequest, textstatus, errorthrown) { dialog({title:'提示', content:"状态:" + textstatus + ";出错提示:" + errorthrown, okvalue:'确定', ok:function (){}}).showmodal(); $("#btnsubmit").val("再次提交"); $("#btnsubmit").prop("disabled", false); $("#chkagree").prop("disabled", false); } });