I have simple form for sending email dato to API, but i want send data via Ajax for not reaload page and give success message under input tag.
HTML:
<form action="" method="POST" class="send-modal-data">
<input type="text" id="send_email" name="subscribe-email" class="modal-input" placeholder="Email *">
<button name="subscribe-form" class="danger-btn send-subscribe">Send</button>
</form>
Ajax
$(function() {
$(".send-subscribe").click(function(e) {
e.preventDefault();
var settings = {
email: $("#send_email"),
"url": "xxxx/api/user/trial/subscribe?email=" + email,
"method": "POST",
"timeout": 0,
};
$.ajax(settings).done(function (response) {
console.log(response);
});
});
});
But when i send email, my modal window closing and not send data, how i can realize with right way ?