I have a form: <form id="form" action="updatescore.php" method="post"> and a php file:updatescore.php which contains the code to update the database using the input values from the form. This all works when using a submit button.
Now I want to remove the submit button and submit the form if a javascript statement is true.
The js code part is:
if (document.getElementById('uhs').innerHTML > 0) { //this is true because the div gone is hidden
$('#gone').hide();
$.ajax({
type: "POST",
data: $("#form").serialize(),
cache: false,
url: "updatescore.php",
success: function () { //if submit to db is done
getUsers(1); //a function to reload a page overview
}
});
}
But nothing happens if the statement is true and the database is not updated. Any ideas on this one?
Kind regards,
Thanks for the replies. The code worked, but it seemed that a bug in another part of the code was messing with the AJAX call. So in the end there was nothing wrong with the code at all.
Again, thanks for the replies and suggestions!