I got a website built for my small business from a freelancer. The website is hosted at http://devopsnexus.com/. Everything looks fine except the form in the bottom which is sending GET instead of POST. Strangely, if I just copy the code within the form tag in a new html file, it works just fine. Now the freelancer has vanished and I am trying to debug since hours without an luck. Can anyone point out what is wrong with html here?
Asked
Active
Viewed 1,130 times
0
-
Please provide relevant code snippets. – AndrewL64 Apr 13 '16 at 20:18
1 Answers
2
The form is being submitted via AJAX in main.js using jQuery's $.ajax(). The form method isn't specified here, and is defaulting to GET. Here's the fix:
// Contact form
var form = $('#main-contact-form');
form.submit(function(event) {
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
var formData = $(this).serialize();
$.ajax({
url: $(this).attr('action'),
method: 'POST',
data: formData,
beforeSend: function() {
form.prepend(form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Email is sending...</p>').fadeIn());
}
}).done(function(data) {
form_status.html('<p class="text-success">Thank you for contact us. As early as possible we will contact you</p>').delay(3000).fadeOut();
});
});

Steve
- 569
- 8
- 20
-
Now the request is being sent as post but none of the parameters are going through. – Aditya Patawari Apr 13 '16 at 20:28
-
I've edited the code above to include the form's serialized data. Try now. – Steve Apr 13 '16 at 20:30
-