Örnek, test etmedim ama muhtemelen çalışır, mantık bu şekilde
<script>
$(".ajaxpost").click(function(){
var form = $(this).attr("data");
post(form);
});
function post(x){
$.ajax({
type:"post",
url :"post_url.php",
data:x.serialize(),
error:alert(),
success:function(response){
console.log(response);
}
})
}
</script>