Skip to content

Instantly share code, notes, and snippets.

@abuslah
Created May 26, 2018 21:25
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 abuslah/1a2f7652bba99a8cd7340c7552662562 to your computer and use it in GitHub Desktop.
Save abuslah/1a2f7652bba99a8cd7340c7552662562 to your computer and use it in GitHub Desktop.
// this is the id of the form
$("#idForm").submit(function(e) {
var url = "path/to/your/script.php"; // the script where you handle the form input.
$.ajax({
type: "POST",
url: url,
data: $("#idForm").serialize(), // serializes the form's elements.
success: function(data)
{
alert(data); // show response from the php script.
}
});
e.preventDefault(); // avoid to execute the actual submit of the form.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment