I'm making an Ajax call which returns me some info including an image path. I prepare all those informations in my HTML which will be displayed as a kind of popup. I just toggle the visibility of by popup div from hidden to visible.
To set the position of my popup div, I have to calculate depending on the height of the image. So, I have to wait for the image to load to know its dimension before setting position and switching visibility to visible.
I tried tricks with recursion, setTimeout, complete img property, while loop... without success.
So, how can I do this. Maybe I should return dimensions in my Ajax call.