Jquery $ .each synchronous

0

I have a GRID on a screen where, each row has a button that calls a javascript method passing some values. In this method, a call is made via getJSON .

The problem is that even in this call, specifying async: false , $.each does not wait to run the next line.

Here is the code for $.each :

console.log('start');
$('#btn_sugerir_todos').click(function(){

    $('.btnSugerir').each(function(index, value) {
        var def = new $.Deferred();
        var id        = $('#' + value.id).attr('data-id');
        var ordcol_id = $('#' + value.id).attr('data-ordcol_id');
        var data      = $('#' + value.id).attr('data-data');
        var hora      = $('#' + value.id).attr('data-hora');
        var cubagem   = $('#' + value.id).attr('data-cubagem');
        var fatexp_id = $('#' + value.id).attr('data-fatexp_id');
        console.log(id);

        sugerirVeiculo(jQPlanejador, id, ordcol_id, data, hora, cubagem, fatexp_id, false);
    });
    console.log('Fim');
});

All console.log() are instantaneous in processing, but the actual result of the sugerirVeiculo() function is not.

Does anyone know how to expect the result line by line?

    
asked by anonymous 23.10.2017 / 22:20

0 answers