Answer the question
In order to leave comments, you need to log in
Updating a record by ajax in the database on click of the block div id, how to implement?
Hello.
---
Background: there is a button
<a href="#add" id="add" data-method="post" class="btn btn-default"> добавить </a>
<form>
Answer the question
In order to leave comments, you need to log in
For those who are looking! This method is called .submit()
<script type="text/javascript">
$(document).ready(function () {
$("#yellow").click(function() {
$("#act form").submit();
});
});
</script>
<div id="act">
<form action="" method="post" data-ajax="post">
<input type="text" id="yellow" name="param">
<input type="submit" value="send">
</form>
</div>
You do not quite understand how it all happens, I think. There is no team that will take and add everything to the database. On the client, you need to catch onclick events (read javascript events), then pass some data to the server via XMLHttpRequest / newer fetch, then process it with any server-side language, including server-side javascript, and add it to the database through it. If you don’t want to write shitty code, it’s better not to use jQuery and other heavyweight and meaningless frameworks at this stage.
By the way, you do not need to wrap the button in a link - links are needed only when you need to take the user to another page with a redraw.
To be honest, it is absolutely not clear what exactly you need to add, and what it means
Let's start simple - where will you get the data from?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question