Jquery ajax load page in infinite loop

Asked

Viewed 180 times

1

I have a button on a page that when clicking it performs the following code:

Note: Whenever I click on this button it reloads a php page with html data, the jquery scripts. But there comes a point q it loops in the search of jquery scripts.

Any idea why this occurs?

$('#return').on('click',function(e){
    e.preventDefault();
    clearChildren(document.getElementById('savepesquisa'));
    $('form')[0].reset();
    blockUnblok(0,idvarejo,4);
    $.ajax({
        url: "pesquisas.php",
        type: "GET",
        success:function(data){$('#loadhtml').html(data);}
    });
});

inserir a descrição da imagem aqui

function blockUnblok(option,idvarejo,status,iduser){
    if(option == 1){
        var blockId = $.ajax({
                            url: 'dadosPS.php?ps=BlockId&id=' + idvarejo + '&idStatus=' + status,
                            dataType: "json",
                            async: false
                        }).responseText;
    }else if(option == 0){
        var unblockId = $.ajax({
                            url: 'dadosPS.php?ps=ReleaseId&id=' + idvarejo + '&idStatus=' + status,
                            dataType: "json",
                            async: false
                        }).responseText;
    }else if(option == 2){
        var updateAgenda = $.ajax({
                            url: 'dadosPS.php?ps=UpdateAgendamento&idStatus=' + status + '&varejo=' + idvarejo + '&idUser=' + iduser,
                            dataType: "json",
                            async: false
                        }).responseText;
    }else{}
}
  • This 'blockUnblok' function is yours?

  • yes Wictor she executes an asynchronous ajax query.

  • Post her code too, the problem may be there.

  • 1

    I updated the code.

  • This blockUnblock code performs a simple update where I get no return from anything.

  • That one blockUnblock is complete? Why can’t I see him updating anything, just catching the responseText of a request synchronous.

  • What comes of the result of the request made in pesquisas.php? Is there any script come together in this result?

  • Just with the passages posted does not make sense this repetition that you mention.

  • In the.php query returns a full page with inputs and functions . and is loaded in a div. when I click on the Return button, it clears the marked inputs and loads the page queries again by ajax.php.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.