I'm using a simple contact form that I've used for other projects but I does not seem to be working properly for my current project. The problem is that it will not show the confirmation message
when you hit the submit button. When i test it on my computer using xampp i don't have this problem. It works fine but when i upload it to the host server and test the contact form it doesn't show the confirmation message. Is this a problem with the host server? or something with with code?
Here is the code for the contact form:
Code:
result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';$("#fields").hide();
Here is the code for the contact form:
Code:
<!-- JQuery: Contact form -->
<script type="text/javascript" src="scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#ajax-contact-form").submit(function(){
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "contact.php",
data: str,
success: function(msg){
$("#note").ajaxComplete(function(event, request, settings){
if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{
result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
$("#fields").hide();
}
else
{
result = msg;
}
$(this).html(result);
});
}
});
return false;
});
});
</script>
Code:
<div id="contact_form">
<fieldset class="info_fieldset"><legend>Inquiry</legend>
<div id="note"></div>
<div id="fields">
<form id="ajax-contact-form" action="javascript:alert('success!');">
<p><label>Name</label>
<input class="textbox" type="text" name="name" value="" /><br />
<label>E-Mail</label>
<input class="textbox" type="text" name="email" value="" /><br />
<label>Subject</label>
<select name="reason">
<option value="">Select...</option>
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 1</option>
<option value="Option 4">Option 1</option>
</select><br />
<label>Best Time:</label>
<select name="time">
<option value="">Select...</option>
<option value="Morning">Morning</option>
<option value="Afternoon">Afternoon</option>
</select><br />
<label>Comments</label>
<textarea class="textbox" name="message" rows="5" cols="25"></textarea><br />
<label> </label>
<input class="button" type="submit" name="submit" value="Send Message" />
<input class="button" type="reset" name="reset" value="Reset" />
</p>
</form>
</div>
</fieldset>
</div>