setting background image to another div's dynamically generated image

setting background image to another div's dynamically generated image

I have   a div set up like this

  1. <div id='y' style='background-image: url(./randomcolor.php?ibase=<?php echo $entity->name; ?>) ....

I am having an issue with setting the background-image of a another div #x to the background image of #y.

Correct me if I am wrong but I think you would do this in a simple case by saying

  1. $('#x').css('background-image',$('#y').css('background-image'));
So when it does it, it is getting the URL of the generator (I logged it.  what is actually being passed is
http://blabla/randomcolor.php?ibase=xyz  Can javascript handle such a thing?   This would require a server call to generate a new image, In this particular application, even if it wasn't exactly the image y had it would be acceptable.  But it's not doing it.    It is not getting any image at all. Am I doing something wrong, i.e. is it supposed to just work?  I would think not, since the page has already been rendered.  This is almost an ajax situation but I don't know how to do it for an image. I don't really want to generate a new image anyway, I'd be very happy to get the one that's already there.    How would I access the actual image already attached to y and not do another server call?