<button onclick="doRequest()">кнопка</button>
function doRequest(){
$.post('myPhpFile.php', {
action: 'doFunctionOnServer'
}, function(data){
});
}
if($_POST['action'] && $_POST['action'] === 'doFunctionOnServer'){
$sql = "INSERT INTO test(id1, date)
VALUES ('$id1','$date')";
}