Ajax Loop Photos
function GetPhotos() {
var row = "<div class='w3-container w3-row-padding'>";
var itemcount = 0;
$.ajax({
url: '/Photos/PhotoList',
type: 'GET',
contentType: 'application/json',
data: "{}",
dataType: "json",
success: function (data) {
var count = Object.keys(data).length;
// var row = "";
$.each(data, function (item) {
if (itemcount % 6 != 0) {
row += "<div class='w3-left w3-padding-16'><div class='w3-container w3-center' style='width: 150px;'><img class='w3-round-xlarge' alt='"+ itemcount +"' onclick=" + "if(event.shiftKey){document.getElementById('dispImage')" + ".src='" + data[item].photoSrc + "';" + "document.getElementById('id01')" + ".style.display='block';}else{if(event.ctrlKey||event.metaKey){$(this).toggleClass('csam');}else{$(this).toggleClass('rev');}}" + " id='" + data[item].photoId + "' src=" + data[item].photoSrc + " data-src=" + data[item].photoSrc + " style='width: 100px;' /></div></div>";
}
if (itemcount % 6 == 0) {
row += "</div>";
row += "<div class='w3-container w3-row-padding'>";
row += "<div class='w3-left w3-padding-16'><div class='w3-container w3-center' style='width: 150px;'><img class='w3-round-xlarge' alt='" + itemcount + "' onclick=" + "if(event.shiftKey){document.getElementById('dispImage')" + ".src='" + data[item].photoSrc + "';" + "document.getElementById('id01')" + ".style.display='block';}else{if(event.ctrlKey||event.metaKey){$(this).toggleClass('csam');}else{$(this).toggleClass('rev');}}" + " id='" + data[item].photoId + "' src=" + data[item].photoSrc + " data-src=" + data[item].photoSrc + " style='width: 100px;' /></div></div>";
}
itemcount++;
});
row += "</div>";
$("#photos").html(row + " itemcount=" + itemcount);
},
error: function (result) {
alert("Error");
}
Comments