[英]Why doesn't the JQuery click event work in combination with submitting a form in Android Web View?
I have the following html form:我有以下 html 表格:
<form id="editForm" method="post" action="/food/update" enctype="multipart/form-data">
<div class="form-group">
<input type="text" name="title" class="form-control">
</div>
<div class="form-group">
<button id="submitEdit" type="submit" name="submit" value="Änderungen speichern">Submit</button>
</div>
</form>
The challenge is to disable the button when the user clicks the submit button to prevent a duplicate http request.挑战是在用户单击提交按钮时禁用该按钮,以防止重复的 http 请求。 Look at my js code.看我的js代码。
$(document).ready(function(){
$(document).on("click", "#submitEdit", function () {
$('form#editForm').submit();
$('#submitEdit').attr('disabled', true);
$('#submitEdit').html('Saving...');
});
});
It works fine on the desktop, but not in web view.它在桌面上运行良好,但在 web 视图中却不行。 In the web view application I click the button, the button text changes to "Saving..." and nothing happens.在 web 视图应用程序中,我单击按钮,按钮文本更改为“正在保存...”,但没有任何反应。 The form isn't send.表格未发送。
I already cleared cache on my mobile before testing.在测试之前,我已经清除了手机上的缓存。
Thank you!谢谢!
Just remove this line of code只需删除这行代码
//$('form#editForm').submit();
$(document).ready(function(){
$(document).on("click", "#submitEdit", function () {
$('#submitEdit').attr('disabled', true);
$('#submitEdit').html('Saving...');
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.