I add a click event handler to an element
$(.elem).click(function(){
$.post(page.php.function(){
//code1
})
})
And then I trigger a click event
$(.elem).click();
//code2
How can i make sure that code2 executes after code1 executes