how do i define the success and failure function of an ajax $.post?
The documentation is here: http://docs.jquery.com/Ajax/jQuery.ajax
But, to summarize, the ajax call takes a bunch of options. the ones you are looking for are error and success.
You would call it like this:
$.ajax({
  url: 'mypage.html',
  success: function(){
    alert('success');
  },
  error: function(){
    alert('failure');
  }
});
I have shown the success and error function taking no arguments, but they can receive arguments.
The error function can take three arguments: XMLHttpRequest, textStatus, and errorThrown.
The success function can take two arguments: data and textStatus. The page you requested will be in the data argument.
If you need a failure function, you can't use the $.get or $.post functions; you will need to call the $.ajax function directly. You pass an options object that can have "success" and "error" callbacks.
Instead of this:
$.post("/post/url.php", parameters, successFunction);
you would use this:
$.ajax({
    url: "/post/url.php",
    type: "POST",
    data: parameters,
    success: successFunction,
    error: errorFunction
});
There are lots of other options available too. The documentation lists all the options available.