0
I have a GRID on a screen where, each line 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
, the $.each
does not wait to rotate the next line.
Follows the code of $.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 the console.log()
are instantaneous in processing, but the actual result of the function sugerirVeiculo()
is not.
Someone knows how forced to wait for the result line by line?
Where’s the asynchronous part? It’s the
sugerirVeiculo
? and where you use thatdef
and why?– Sergio
The
def
can ignore, does nothing. It was an attempt of mine to solve the problem.– Mario de M. Barros Neto
Within the
sugerirVeiculo
, i usegetJSON
. I defined him withasync: false
but still, it’s asynchronous.– Mario de M. Barros Neto
You can show the code of this
sugerirVeiculo
to better understand what it takes?– Sergio