Skip to content

Instantly share code, notes, and snippets.

@montague
Created September 6, 2011 18:50
Show Gist options
  • Save montague/1198598 to your computer and use it in GitHub Desktop.
Save montague/1198598 to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript" charset="utf-8">
$(function(){
$('#submit_button').click(function(){
var url = "/post/to/this/url";
$.post(url, $('form').serialize(), function(responseData, ajaxStatus){
//this is the callback function that fires upon completion of the ajax post request
//the 'data' parameter holds whatever the server returned in response to to the post request
//here, i am assuming the server returns a message that is intended to be displayed to the user ("missing data", "info submitted", etc)
$('#status').text(data);
});
});
});
</script>
</head>
<body>
<form>
<input id="fuck" name="fuck"/>
<input id="you" name="you"/>
</form>
<div id="status">waiting...</div>
<button id="submit_button">submit some shit</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment