Load jquery and pass data to you action through a POST request on click of your button like this , hope this helps
HTML :
<input type="button" id="button" value="Say Hello">
JS:
$(document).ready(function(){
$("#button").click(function (){
var name = $('#name').val(); //your code has $(#name) which is not selecting required input element!
$.post("/cardselector/mailAction.do",{"name" : name},function(response)
{
alert("done");
console.log(response); //see what response you are getting
});
})
; });