I have a form with a div as a button, which acts as a close button for another div.
When I click on the form, I want two things to happen:
- Close the parent div (I already managed that), and
- Run a PHP script (I'm stuck here).
This is how far I got:
<form action="/alert.php" method="post">
<div class="alert-close">×</div>
</form>
<script>
$(document).ready(function(c) {
$('.alert-close').on('click', function(c) {
$(this).parent().fadeOut('slow', function(c) {});
});
});
</script>
I thought about implementing a code like this:
$.ajax({
url: $form.attr('action'),
method: $form.attr('method'),
});
but I don't know where it belongs as I'm a noob with AJAX and JavaScript. What do I need to do?