Hello everyone, I would like to do a load on demand, but I can not mount. Here is my code:
function show(letra) {
var itens = "";
$.ajax({
type: 'GET',
dataType: 'json',
data: 'action_search=yes&letra=' + letra,
url: '<?= CAMINHO_ADMIN; ?>/modulos/responds.php',
beforeSend: function () {
$('.load').show();
$('ul#alfabeto-itens').empty();
},
success: function (dados) {
$('.load').hide();
for (var i = 0; i < dados.length; i++) {
$('ul#alfabeto-itens').append('<li class="hg-services__item"><a href="<?= BASE; ?>/exames/' + dados[i].post_name + '"><span>' + dados[i].post_title + '</span></a></li>');
}
}
});
}
$(function () {
$('tr#search-indexes').on('click', 'a.letra_click', function (e) {
var res = $(this).attr('search-letra');
$(this).siblings('a').removeClass('active');
$(this).addClass('active');
e.preventDefault();
show(res);
});
}
});
Explanation of the above code: Starting the jquery function, I have a list of A-Z buttons, when I click on a letter, I return in json via ajax, all that is equal to the clicked letter. This ajax request, is performed from the function "show (letter)", it is in this function that I return my request php with ajax and json, good from this function I can not do the loading on demand until I found it here and on the internet , tutorials for on-demand loading, but I did not find the kind of framework I'm doing.
So, I wish someone could help me with this problem, I'll be grateful.
Att,
Alisson