Skip to content

Instantly share code, notes, and snippets.

@jglozano
Created April 16, 2010 04:42
Show Gist options
  • Save jglozano/368014 to your computer and use it in GitHub Desktop.
Save jglozano/368014 to your computer and use it in GitHub Desktop.
$(function () {
$("#personCreate").click(function () {
var person = getPerson();
// poor man's validation
if (person == null) {
alert("Specify a name please!");
return;
}
// take the data and post it via json
$.post("home/save", person, function (data) {
// get the result and do some magic with it
var message = data.Message;
$("#resultMessage").html(message);
});
});
});
function getPerson() {
var name = $("#Name").val();
var age = $("#Age").val();
// poor man's validation
return (name == "") ? null : { Name: name, Age: age };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment