Two Ajax requests in the same function

1

When loading a page, I have two Ajax requests in a sequence that populate two select's with the options that come from different tables in the database.

But only the first one is executed, the second does not even call. I've followed debugging, put breakpoint to see if the second request comes in and does not work.

The two are independent. Here is the code:

function Inicio(){
   // Primeira requisição que é executada
   $.get('ctrl/administrativo/modcadcon.ctrl.php',
           {'acao':'todos_atv', 'campo':'mod_status', 'valor':'1'},
           function(ret_mod){

           // Preenche o select com o resultado

           }
   );

   // Segunda requisição não é executada
   $.get('ctrl/administrativo/procadcon.ctrl.php',
           {'acao':'consultar', 'campo':'pro_status', 'valor':'1'},
           function(ret_pro){

           // Não chega aqui...!
           }
   );
}

[RESOLVED]

There was an error in the PHP script that received the second request ... Now both work.

    
asked by anonymous 02.08.2018 / 17:32

1 answer

0

Try this:

function Inicio(){
   // Primeira requisição que é executada
   $.get('ctrl/administrativo/modcadcon.ctrl.php',{'acao':'todos_atv', 'campo':'mod_status', 'valor':'1'})
         .done(function( data ) {
            console.log('Preenche o select com : ' + data)
            $.get('ctrl/administrativo/procadcon.ctrl.php',{'acao':'consultar', 'campo':'pro_status', 'valor':'1'})
               .done(function( data2 ) {
                  console.log('Preenche o select com : ' + data2)
               });
         });
  }
    
02.08.2018 / 18:03