Skip to content

Instantly share code, notes, and snippets.

@zvineyard
Created March 11, 2012 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zvineyard/2018168 to your computer and use it in GitHub Desktop.
Save zvineyard/2018168 to your computer and use it in GitHub Desktop.
jQuery: POST example
$('#infoForm').submit(function() {
var postTo = 'http://yourdomain.com/test.php';
$.post(postTo,({first_name: $('[name=first_name]').val(), last_name: $('[name=last_name]').val(), email: $('[name=email]').val()}),
function(data) {
alert(data);
if(data != "") {
// do something
} else {
// couldn't connect
}
},'json');
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment