Good afternoon! My Jquery is adding the results obtained via ajax and they are disappearing. What could be happening? And how to solve? Thanks
var _urlSearchInput;
var _urlSearch;
$('#vai').click(function(){
_urlSearchInput = $('#campo-busca').val();
_urlSearch = window.location.origin + "/search/" + _urlSearchInput + "/";
//alert(_urlSearch);
//alert(_urlSearchInput);
$.ajax({
url: _urlSearch,
dataType: "json",
type: "post",
success: function(json) {
var html;
var matias = json;
if(typeof json == 'string'){
matias = JSON.parse(json);
}
for(item in matias){
html += '<div class="media wow fadeInDown animated" style="visibility: visible; animation-name: fadeInDown;">';
if (typeof matias[item].midias['102x112'] != 'undefined'){
html += '<a href="#" class="media-left">';
html += '<img alt="" src="' + matias[item].midias['102x112'] + '">';
html += '</a>';
}
html += '<div class="media-body">';
html += '<h4 class="media-heading">';
html += '<a href="'+ matias[item].url +'">' + matias[item].title + '</a>';
html += '</h4>';
html += '<p>' + ( !matias[item].description ? '' : matias[item].description) + '</p>';
html += '</div>';
html +='</div>';
}
$('#resultados-busca').append(html.replace("undefined", ""));
}
});
});