What are callbacks for? Pass the function to one of the parameters $.post(), and it will be executed only when the request is successful:
$.post("test.php", function(data) {
alert("Data Loaded: " + data);
});
document.write('This won`t wait for ajax');
alert() ajax, document.write() , .