Created
August 28, 2015 10:56
-
-
Save franhaselden/5ab3e5e4874ccbbeff21 to your computer and use it in GitHub Desktop.
Post form with AJAX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is the id of the form | |
$("#idForm").submit(function() { | |
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. | |
} | |
}); | |
return false; // 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