So what I want to do I'm sure has been done thousands of times. I am just having trouble finding the solution.
I am receiving some JSON data that looks like this
{"ImageCollection":
{"Images":
[{ "ImageID":"68",
"CatID":"1",
"Location":"/Images/Art/Full/68.gif",
"ClipLocation":"/Images/Art/Clips/68.gif",
"FullHeight":"504",
"FullWidth":"451"
},
{ "ImageID":"69",
"CatID":"1",
"Location":"/Images/Art/Full/69.gif",
"ClipLocation":"/Images/Art/Clips/69.gif",
"FullHeight":"364",
"FullWidth":"500"
},
etc. etc
]
}
}
and I want to display the images in a table that is 4 columns wide. I have the following
<script type="text/javascript">
$.getJSON("/Service/GetJson.ashx?data=images", function(data) {
var jsObjectData = data.ImageCollection.Images;
var imageTable = "<table><tbody>";
var rowMarker = 1;
var targetRowEnd;
$.each(jsObjectData, function(i, item) {
if (
imageTable = imageTable + "<td class='artImageBox'>";
imageTable = imageTable + "<a title='Click To Add' class='artImage'>";
imageTable = imageTable + "<img id='ArtImg";
imageTable = imageTable + item.ImageID;
imageTable = imageTable + "' src='../";
imageTable = imageTable + item.ClipLocation;
imageTable = imageTable + "' alt='Click To Add' />";
imageTable = imageTable + "</a></td>";
});
imageTable = imageTable + "</tbody></table>";
alert(imageTable);
$("body").append(imageTable);
});
</script>
But I have not had any luck in calculating where to place the the <tr> and the </tr>
.