尝试从 JQuery 触发提交功能。我究竟做错了什么?从理论上讲,这应该可行。我已经尝试了大约 4 种不同的方法。
我努力了
$('input#submit').trigger("click");
$( form:first ).submit();
$( form:first ).trigger("submit");
$('form#databaseActionForm').submit();
Run Code Online (Sandbox Code Playgroud)
什么都没有起作用(还)?!
代码:
<html lang="en">
<head>
<title>Database Management</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<script src="http://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
<style>
table td { border: 1px solid black; }
table td:first-child { text-align: left; }
</style>
<script>
<!--
$(document).ready(function() {
$('#erase').click(function() {
if (confirm("Are you sure that you want to ERASE ALL DATA from the database?"))
{
$('#buttonTypePressed').val("erase");
$('input#submit').trigger("click"); <!-- HERE -->
}
});
$('#update').click(function() {
var appID = $('#updateAppID').val();
var …
Run Code Online (Sandbox Code Playgroud)