I would like to send an ajax command to a php script each time when a button is clicked. The divs are called r, l, t, b for the different directions. So far I have tried using the code below. But somehow it doesn't work. I have not a lot of experience in jquery and that's why I am asking here for a simple solution. I could write 4 times the same function but this is certainly not what I am looking for.
$(document).ready(function(){
function control(id){
$.ajax({
type: "POST",
url: "control.php",
data: {id: "1"},
success: function(data){
alert(data);
}
});
}
$('#r').mousedown(function(){
control($(this).attr('id'));
});
});