$('#id').click(function(){
      ajax_my(post)
});
function ajax_my(post)
{
          var serverAdress = '/url/';
          posl_ = encodeURIComponent(post);
          pushPOST = 'mypost=' + turl_;
          $.ajax({
	         type: "POST",
	         url: serverAdress,
                    cache: false,
	        data: pushPOST,
                    dataType: "json",
                    timeout: 10000,
                    async: false,
                    beforeSend: function(){},
                    success: function(){все получилось},
                    error:  function(xhr, str){
                            	    alert('Возникла ошибка: ' + str);
                                    
                            	                  }
		  });
}
как нибудь так