Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Implementing jQuery AJAX into contact form

Featured Replies

Hi guys,

 

I want to implement AJAX into a contact a contact form, here is the code I have so far...

 

$("#contact_form").validate({
 meta: "validate",
 submitHandler: function (form) {
	 $('#contact_form').hide();
	 $('#sucessmessage').append("<h4 class='form_thanks'>Thanks, your email has been sent! We will get back to you as soon as possible</h4>");
	 return false;
	 form.submit();
 },
 /* */
 rules: {
	 name: "required",

lastname: "required",
	 // simple rule, converted to {required:true}
	 email: { // compound rule
		 required: true,
		 email: true
	 },
	 subject: {
		 required: true,
	 },
	 message: {
		 required: true
	 }
 },
 messages: {
	 name: "Please enter your name.",
lastname: "Please enter your last name.",
	 email: {
		 required: "Please enter email.",
		 email: "Please enter valid email"
	 },
	 subject: "Please enter a subject.",
	 message: "Please enter a message."
 },
}); /*========================================*/
});

 

How do I implement AJAX jQuery code into this (posting to a PHP file)?

 

Thanks

 

Matt

 

EDIT: Sorry about the indentation, I'm tidier than that, I blame Dreamweaver though :p

Edited by Matt Maclennan

You would use $.ajax heres an example posting to a php file

 

var DataString = $("#FormId").serialize();
$.ajax({
type:"POST",
url:"ajax/form-parse.php",
data:DataString,
cache:false,
success:function(html){
$("#Inter_Div").html(html);
}
});

 

if you need any further help feel free to message me

Edited by webdesigner93

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.