July 20, 200917 yr Hi guys, I'm working on an AJAX/jQuery form at the moment. The form functions perfectly at the moment, the only thing I would like to do is when the form is valid and eventually been sent to the email, the div which holds the form is hidden to prevent the user constantly hitting submit. The code for the form at the moment is as follows: //engage on the page load $(function() { //trigger ajax on submit $('#enquiry').submit( function(){ //hide the form //$('#enquiryContainer').hide(); //show the loading bar $('#loader').append($('.bar')); $('#bar').css({display:'block'}); //send the ajax request $.get('sendEnquiry.php',{name:$('#name').val(), telephone:$('#telephone').val(), type:$('#type').val(), email:$('#email').val(), message:$('#message').val() }, //return the data function(data){ //hide the graphic $('#bar').css({display:'none'}); $('#errors').text(''); $('#errors').fadeIn(3000); $('#errors').append(data); }); //stay on the page return false; }); }); I need something to say, if the response of the Ajax request is "Thankyou for submitting your enquiry..." then hide the form. Anyone have any ideas?
July 20, 200917 yr just to make this quick and painless. there is a great script at http://trevordavis.net/contact-form/ - obviously you only need to pay attention to the jquery script but its very simple and does validation well too.
Create an account or sign in to comment