How to refresh a coded block when a flag is clicked in it?
The easiest way would be to use the module Block Refresh. With this module you can set up any block to be reloaded both manually and by an interval. For your use case you would chose the first option, here is an example form the block configuration page:


You will see now a refresh button on blocks title, which could be hidden by the following CSS:

.block-refresh-button {
    display:none;
}


and then triggered by clicking the flag:

$(".flag").click(function() {
    $(".block-refresh-button").each(function() {
        $(this).click();
    });
});


I did not test the code.