0
I have a section where you receive some posts and have a button to press more. In my Section the first post displays correctly, but when I click the button to press more, does not run the second post q was to appear.
My Section | add-on/Section-a.php = Location my Section
My button | add-on/Section.botao.php = Where my button is
My javascript | add-on/load_mais_js.js = Location of my button
//Carrega um conteúdo inicial ao carregar a página
$(document).ready(function(){
$.ajax({
url: 'complemento/section-um.php',
data: {PG:1},
type: 'GET',
success: function(response){
$('#Section_index_NV').html(response);
}
});
});
//Carrega um conteúdo ao clicar no botão
$(document).ready(function(){
$('#CarregarNVs').click(function(){
let proxima_pagina = $(this).attr('data-ref');
$.ajax({
url: 'complemento/section-um.php',
data: {PG:proxima_pagina},
type: 'GET',
success: function(response){
console.log(response);
$('#Section_index_NV').append(response);
},
complete: function(){
$('#CarregarNVs').attr('data-ref', parseInt(proxima_pagina) + 1);
}
});
});
});
Page of my button:
<div class="Carregar_mais">
<center>
<button id="CarregarNVs" title="Carregar mais" class="CarregarNVs" data-ref="2">Carregar mais</button>
</center>
</div>
What happens, is there an error in the console? It falls into ajax error callback, does not render on the screen..?
– BrTkCa
the console does not return any error, but now q I took a look, when I click the button it runs only part of the title of my Section (Ie it duplicates the beginning of the Section, but n appears another post).
– EDGNoizy
You have sent a
data
in aGET
, would not bePOST
?– BrTkCa
Yes that was msm, was how GET switched to the POST and it worked. Thank you.
– EDGNoizy