I treid to arrange images in six columns like but its repeating the images
$(document).ready(function () {
alert('Hello');
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default4.aspx/BindDatatable",
data: "{}",
dataType: "json",
success: function (data) {
var imgs;
for (var i = 0; i < data.d.length; i++) {
$("#gvDetails").append("<tr><td><img src=" + data.d[i].ImagePath + " height='60px' width='100px' ></img></td><td><img src=" + data.d[i + 1].ImagePath + " height='60px' width='100px' ></img></td><td><img src=" + data.d[i + 2].ImagePath + " height='60px' width='100px' ></img></td><td><img src=" + data.d[i + 3].ImagePath + " height='60px' width='100px' ></img></td><td><img src=" + data.d[i + 4].ImagePath + " height='60px' width='100px' ></img></td><td><img src=" + data.d[i + 5].ImagePath + " height='60px' width='100px' ></img></td></tr>");
}
},
error: function (result) {
alert("Error");
}
});
});
so how to avoid repeating images and arrange it as per images count?
TRY THIS Change Your success function something like that. note(i don't know what is your data return) it may work for you.
success: function (data) {
var el = "<tr>";
for (var i = 0; i < data.d.length; i++) {
if ( i%6 == 0 ) {
el += "</tr><tr>"
}
el += "<td><img src=" + data.d[i].ImagePath + " height='60px' width='100px' /></td>");
}
el += '</tr>';
$("#gvDetails").append( $(el) );
}