I am using contact form plugin for forms in my craft website. For avoiding page redirection, I followed ajax submit for the form, but it is not redirected to controller code.
My form is as below:-
<form method="post" action="" accept-charset="UTF-8" class="basic-form" id="contactForm">
{{ csrfInput() }}
<input type="hidden" name="action" value="contact-form/send">
<div class="form-group">
<input type="text" class="text-field" id="text-630573652" name="firstName" value="" required="" placeholder="Name *" autocomplete="off">
</div>
<div class="layout-sm-12">
<button type="submit" class="btn white-btn-outline submit-btn">LET'S TALK<i class="icon-long-arrow-bold-right"></i></button>
</div>
</form>
My ajax script is as follows:-
$(function () {
$('#contactForm').on('submit', function (e) {
e.preventDefault();
$.ajax({
type: 'post',
url: '/',
data: $('#contactForm').serialize(),
dataType: 'json',
success: function (response) {
alert(response);
}
});
});
});
For this I am getting error in console like 404 page not found. How to redirect to send controller index function using ajax request. As per other tutorials '/' is not working here.
Anyone please help...