Jquery ajax load page in infinite loop

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 data in html, the jquery scripts. But there comes a point where it loops in the jquery scripts search.

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);}
    });
});

functionblockUnblok(option,idvarejo,status,iduser){if(option==1){varblockId=$.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{}
}
    
asked by anonymous 06.10.2017 / 15:29

0 answers