Skip to content

Instantly share code, notes, and snippets.

@albertein
Created November 9, 2011 17:23
Show Gist options
  • Save albertein/1352164 to your computer and use it in GitHub Desktop.
Save albertein/1352164 to your computer and use it in GitHub Desktop.
Simple jQuery Ajax example.
<!DOCTYPE html>
<html>
<head>
<title>DEMO</title>
<script src="urlToJQuery"></script>
<script>
$(document).ready(function() {
$("#sumbit-button").click(function(){
var name = $("#name").val();
var age = $("#age").val();
//Validate if needed
$.post("example.php", { name: name, age: age }, function(data) {
$("#results-pane").html(data).show("slow");
}, "html");
});
});
</script>
<style type="text/css">
#results-pane {
display: none;
}
</style>
</head>
<body>
<form>
<input type="text" id="name" />
<input type="text" id="age" />
<input type="button" id="submit-button" />
</form>
<div id="results-pane"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment