After form have been successfully submitted message will be displayed in “H4.output_message”. with following ajax code.
$(document).ready(function() {
$('.get-form').on('submit',function(){
// Add text 'loading...' right after clicking on the submit button.
$('.output_message').text('Loading...');
var form = $(this);
$.ajax({
url: form.attr('action'),
method: form.attr('method'),
data: form.serialize(),
success: function(result){
$("form")[0].reset();
if (result == 'success'){
$('.output_message').text('Message Sent!');
} else {
$('.output_message').text('Error Sending email!');
}
}
});
return false;
});
});
Everything works fine but i want hide “div.form-fill” when h4.out_message is empty as i have done some css styling. i want to display “div.form-fill” only when h4.out_message have some text.
Works fine with JavaScript but couldn’t figure out with ajax
whole mail function and ajax callback in called in action=“get-quote.php”.
h4.out_message will be empty when page loads… ajax will generate some text on form submit
so i want div.form-fill to hidden (display:none) when empty when ajax update innerHTML after submission of form i want to remove display none so that div.form-fill is visible with css style