It's working option.
<script>
    function language($id, $lang){
        //get the input value
        $.ajax({
            //the url to send the data to
            url: "modules/tca/updatedb.php",
            //the data to send to
            data: {id : $id, lang: $lang},
            //type. for eg: GET, POST
            type: "POST",
            //on success
            success: function(data){
                console.log("***********Success***************"); //You can remove here
                console.log(data); //You can remove here
            },
            //on error
            error: function(){
                    console.log("***********Error***************"); //You can remove here
                    console.log(data); //You can remove here
            }
        });
    }
</script>
And in Body:
<li><a href="#en" onclick="language(1,'en')"><span class="flag flag-usa flag-1x" ></span>EN</a></li>
<li><a href="#fr" onclick="language(2,'fr')"><span class="flag flag-frc flag-1x"></span> FR</a></li>
And your post page (in this example your modules/tca/updatedb.php)
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "code";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
$id = $_POST['id'];
$lang= $_POST['lang'];
$sql = "UPDATE users SET lang='$lang' WHERE id = '$id'";
if ($conn->query($sql) === TRUE) {
    echo "New record updated successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>