exec, a если так ?
$.ajax({
type: "POST",
url: "/rand_header.php",
data: "userHour="+myHour,
success: function(pic){
myImage = new Image();
function write(){
$('#header').css('backgroundImage', 'url('+myImage.src+')');
$('#header').animate({'opacity':'1'}, 230);
}
myImage.onload = write;
myImage.src = '/themes/images'+pic;
}
});