Created
April 16, 2010 04:42
-
-
Save jglozano/368014 to your computer and use it in GitHub Desktop.
This file contains 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
$(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