避免表单多次提交
1:提交后将Submit按钮设为Disable
<div id="SpecialBrokerageEdit"> @using (Html.BeginForm("AddSpecialBrokerage", "BrokerageStandard", FormMethod.Post, new { id = "frmSpecialBrokerageEdit" })) { @Html.HiddenFor(m => m.SpBrokerageStdId) @Html.HiddenFor(m => m.SpecialBrokerageId) <table> <tr> <td>@Html.LabelFor(m => m.SpSiteId)</td> <td> @Html.TextBoxFor(m => m.SpSiteId) @Html.ValidationMessageFor(m => m.SpSiteId) </td> </tr> <tr> <td> <label>佣金分配:</label> </td> </tr> <tr> <td>@Html.LabelFor(m => m.SpMediaPercent)</td> <td> @Html.TextBoxFor(m => m.SpMediaPercent)<label name="SpPercentTypeLog">元</label> @Html.ValidationMessageFor(m => m.SpMediaPercent) </td> </tr> <tr> <td>@Html.LabelFor(m => m.SpPlatformPercent)</td> <td> @Html.TextBoxFor(m => m.SpPlatformPercent)<label name="SpPercentTypeLog">元</label> @Html.ValidationMessageFor(m => m.SpPlatformPercent) </td> </tr> </table> <div class="buttoncontainer"> <input style="width:50px;height:30px;" type="submit" value="确定" id="btnspecialBrokerageSave" /> <input style="width:50px;height:30px;" type="button" value="取消" id="btnspecialBrokerageCancel" /> </div> } </div>
var options = { beforeSubmit: function () { var itemBtn = $("#btnspecialBrokerageSave"); itemBtn.prop("disabled", "disabled"); setTimeout(function () { itemBtn.removeAttr("disabled"); }, 2000); return false; }, success: function (data) { if (data.Status == 1) { info.btnSearchSpecialBrokerage.click(); infoSpecial.btnspecialBrokerageCancel.click(); } else { alert(data.Message); } } }; $('#frmSpecialBrokerageEdit').ajaxForm(options);