A
adam
I have a rather old script that uses XMLHttpRequest to retrieve some
html and pops it into a div using innerHTML. I'd like to switch over to
using append child since not only is it standardized, but it'll save me
bandwidth in the long run.
The html returned looks something like:
----
<div style="position:absolute; z-index:50; width:256px; height:256px;
top:0px; left:0px">'.$tilesOverlay[NW].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:0px; left:256px">'.$tilesOverlay[NC].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:0px; left:512px">'.$tilesOverlay[NE].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:256px; left:0px">'.$tilesOverlay[W].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:256px; left:256px">'.$tilesOverlay[C].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:256px; left:512px">'.$tilesOverlay[E].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:512px; left:0px">'.$tilesOverlay[SW].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:512px; left:256px">'.$tilesOverlay[SC].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:512px; left:512px">'.$tilesOverlay[SE].'</div>
---
with obvious php elements in there.
as there's a total of nine divs, creating each of them and setting
their properties in a little loop shouldn't be a problem, but once I
start thinking of sending the remaining data over as a string and then
parsing through it as an array within the javascript, I'm struck there
must be an easier way. particularly since the z-index will change,
depending on what's calling that function.
Am I just being lazy, or am I missing something?
html and pops it into a div using innerHTML. I'd like to switch over to
using append child since not only is it standardized, but it'll save me
bandwidth in the long run.
The html returned looks something like:
----
<div style="position:absolute; z-index:50; width:256px; height:256px;
top:0px; left:0px">'.$tilesOverlay[NW].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:0px; left:256px">'.$tilesOverlay[NC].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:0px; left:512px">'.$tilesOverlay[NE].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:256px; left:0px">'.$tilesOverlay[W].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:256px; left:256px">'.$tilesOverlay[C].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:256px; left:512px">'.$tilesOverlay[E].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:512px; left:0px">'.$tilesOverlay[SW].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:512px; left:256px">'.$tilesOverlay[SC].'</div>
<div style="position:absolute; z-index:50; width:256px;
height:256px; top:512px; left:512px">'.$tilesOverlay[SE].'</div>
---
with obvious php elements in there.
as there's a total of nine divs, creating each of them and setting
their properties in a little loop shouldn't be a problem, but once I
start thinking of sending the remaining data over as a string and then
parsing through it as an array within the javascript, I'm struck there
must be an easier way. particularly since the z-index will change,
depending on what's calling that function.
Am I just being lazy, or am I missing something?