 <p>Your code had too many errors due to mismatch of " &amp; '. Fixed:</p> <pre><code>$("#busca").on('click', function() { $.ajax({ type : "POST", url : "service.php", dataType : "json", data : { action : "fullProjects", }, success : function(data) { var i; for ( i = 0; i &lt; data.data.length; ++i) { console.log(i); var thisData = data.data[i]; var divCreator = ''; divCreator += '&lt;div id="grupo' + i + '" class="typeface-js" style="font-family:GreyscaleBasic"&gt;'; divCreator += '&lt;div class="tipo-pro"&gt;'; divCreator += '&lt;div id="tipo_' + i + '" class="tipo"&gt;&lt;/div&gt;'; divCreator += '&lt;div id="tipo_arq_abajo' + i + '" class="abajo"&gt;&lt;/div&gt;'; divCreator += '&lt;/div&gt;'; divCreator += '&lt;div id="fotoproyectos' + i + '" class="foto"&gt;&lt;img src="' + thisData.path + '" height="128" width="160"&gt;&lt;/div&gt;'; divCreator += '&lt;div id="nombreproyectos' + i + '" class="nombre-pro"&gt;&lt;form method="post" name="projectsearch" id="projectsearch' + i + '" action="proyectos_arq.php"&gt;'; divCreator += '&lt;span style="cursor: pointer;" onclick="document.getElementById("projectsearch' + i + '").submit()"&gt;' + thisData.projectName + '&lt;/span&gt;'; divCreator += '&lt;input name=\"project_id\" type=\"hidden\" id=\"project_id\" value="' + thisData.projectId + '"&gt;'; divCreator += '&lt;/form&gt;&lt;/div&gt;'; divCreator += '&lt;/div&gt;'; divCreator += '&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;'; $("#contiene-pro").append(divCreator); }; } }); }); </code></pre>