Skip to content

Instantly share code, notes, and snippets.

@darkfrog26
Created July 4, 2012 15:57
Show Gist options
  • Save darkfrog26/3048034 to your computer and use it in GitHub Desktop.
Save darkfrog26/3048034 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Ajax POST Example</title>
<script src="/js/jquery-1.7.2.js"></script>
</head>
<body>
<form id="postForm" action="/">
<label>Name</label>
<input name="name" type="text"/>
<label>Phone</label>
<input name="phone" type="text"/>
<input type="submit"/>
</form>
<div id="result"></div>
<script>
$("#postForm").submit(function(event) {
event.preventDefault();
$.post("/service/postexample", $("#postForm").serialize(), function(data) {
alert('Testing: ' + data.message);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment