Skip to content

Instantly share code, notes, and snippets.

@psdtohtml5
Created March 14, 2013 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psdtohtml5/5160807 to your computer and use it in GitHub Desktop.
Save psdtohtml5/5160807 to your computer and use it in GitHub Desktop.
jQuery : Ajax Request
$("#contact-form").submit(function(e) {
e.preventDefault();
var name = $("#name").val(),
email = $("#email").val(),
subject = $("#subject").val(),
message = $("#message").val();
$.ajax({
type: "POST",
url: "contact.php",
data: {
submit: true,
name: name,
email: email,
subject: subject,
message: message
},
beforeSend: function ( xhr ) {
$("#status").show().html("<img src='images/preloader.gif' width='32' height='32' alt='sending email...'>");
}
}).done(function( response ) {
$("#status").html(response);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment