Skip to content

Instantly share code, notes, and snippets.

@ryanburgess
Created December 19, 2013 22:34
Show Gist options
  • Select an option

  • Save ryanburgess/8047410 to your computer and use it in GitHub Desktop.

Select an option

Save ryanburgess/8047410 to your computer and use it in GitHub Desktop.
Submit form action using AJAX and prevent page refresh or redirect.
$("form").on("submit",function(event){
event.preventDefault();
$.ajax({
type: "POST",
cache: false,
url: $(this).attr("action"),
data: $(this).serialize(),
success: function( data ) {
// put success action here
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment