gpt4 book ai didi

javascript - 单击后使按钮只读

转载 作者:行者123 更新时间:2023-11-28 05:15:03 25 4
gpt4 key购买 nike

所以我有一个包含多个按钮的表单,每个按钮在 Controller 中都有一个请求映射。

所以我想停止重复提交表单,但我无法在单击后禁用该按钮,因为 Controller 无法获得它需要知道该做什么的信息。这是我得到的错误:

org.springframework.web.bind.UnsatisfiedServletRequestParameterException: Parameter conditions "update" OR "verify" OR "reject" OR "updateCard" OR "approve" OR "withdraw" OR "updateStatusToReject" OR "updateStatusToApprove" not met for actual request parameters:

所以我觉得在点击后将按钮设置为只读可以解决这个问题。

到目前为止我已经尝试过了,但它仍然允许双重提交。

 $('.sendButton').click(function(){
$(this).prop('readonly', true);
});



<c:if test="${requestForm.status == 'R'}">
<input type="submit" name="updateStatusToApprove" value="Update To Approved" tabindex="7"
class="sendButton" id="appealA"/>

</c:if>
<c:if test="${requestForm.status == 'A' || requestForm.status == 'AA'}">
<input type="submit" name="updateStatusToReject" value="Update To Rejected" tabindex="8"
class="sendButton" id="appealR"/>

关于如何在不实际禁用按钮的情况下停止双重提交的任何想法。

最佳答案

让您的输入 类型 按钮 并分配一个click 处理程序,使用one 只执行一次

$('.sendButton').one( "click", function(){
//submit the form
$(this).closest('form').submit();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" name="updateStatusToReject" value="Update To Rejected" tabindex="8" class="sendButton" id="appealR"/>

关于javascript - 单击后使按钮只读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47413249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com