Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

diasgabrie

js que chama php, js não funciona na página chamada?

Recommended Posts

olá amigos,

 

tenho uma paginação na PG.PHP em js q ao rolar a pagina para baixo vai mostrando novos resultados:

$(document).ready(function() {
    var track_load = 0; //total loaded record group(s)
    var loading  = false; //to prevents multipal ajax loads
    var total_groups = 5; //total record group(s)

    $('#results').load('autoload.php', {'page':track_load}, function() {track_load++;}); //load first group
    
    $(window).scroll(function() { //detect page scroll
        
        if($(window).scrollTop() + $(window).height() == $(document).height())  //user scrolled to bottom of the page?
        {
            
            if(track_load <= total_groups && loading==false) //there's more data to load
            {
                loading = true; //prevent further ajax loading
                $('.animation_image').show(); //show loading image
                
                //load data from the server using a HTTP POST request
                $.post('autoload.php',{'group_no': track_load}, function(data){
                                    
                    $("#results").append(data); //append received data into the element

                    //hide loading image
                    $('.animation_image').hide(); //hide loading image once data is received
                    
                    track_load++; //loaded group increment
                    loading = false; 
                
                }).fail(function(xhr, ajaxOptions, thrownError) { //any errors?
                    
                    alert(thrownError); //alert with HTTP error
                    $('.animation_image').hide(); //hide loading image
                    loading = false;
                
                });
                
            }
        }
    });
});

tudo ok, o PG.PHP chama a autoload.php ao rolar a página. acontece que o PG.PHP tem um script que é um botão de like no meu site. Gostaria de fazer esse botão funcionar no conteudo aberto pelo autoload.php sem ter que colocar <script> no autoload.php pois da erro.

 

Como posso fazer os scripts da paginação, ou seja, do AUTOLOAD.PHP funcionar sem ter que colocar <script> novamente no autoload?

 

muito obrigada!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.