Hello everyone, I have a problem and I wanted help.
How can I make a for
within html +=
of ajax?
JS:
$('.requerAjax').click(function(e) {
e.preventDefault();
var mes = $(this).attr('rel');
$.ajax({
type: "POST",
url: "/admin/galeria/fotos-ajax",
data: "mes="+ mes,
datatype: 'json',
beforeSend: function(){
},
success: function(result){
var i = 0;
var result = result[i];
// console.log(result);
var html = "";
html += "<div id="+ result.mes + result.ano +" class='modal fade' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>";
html += "<div class='modal-dialog'>";
html += "<div class='modal-content'>";
html += "<div class='modal-header'>";
html += "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>";
html += "<h4 class='modal-title'>"+ result.mes +"/"+ result.ano +"</h4>";
html += "</div>";
html += "<div class='modal-body'>";
html += "<div class='gallery'>";
// for ( $i < result.length; $i++) {
html += "<img src="+ result.imagem +" alt=''>";
// }
html += "</div>";
html += "</div>";
html += "<div class='modal-footer'>";
html += "<button type='button' class='btn btn-default' data-dismiss='modal' aria-hidden='true'>Fechar</button>";
html += "</div>";
html += "</div>";
html += "</div>";
html += "</div>"
$( ".areaModal" ).html(html);
}
});
I have a modal that inside it will come several photos. I want to put the For inside the modal, here inside:
html += "<div class='gallery'>";
// for ( $i < result.length; $i++) {
html += "<img src="+ result.imagem +" alt=''>";
// }
html += "</div>";