1
I’m doing a method that goes in the comic book makes a query and returns the codes.
With these codes I charge to Combobox
with the respective items.
There are times that fill in neat, there are times that don’t fill out... Some idea?
$.getJSON("carrega.php?id_usuario=" + id_usuario + "&id_cord=" + id_cordao,function(data){
$.each(data.cord, function(i,user){
//Carrega o Combo com o Valor do BD
$('#cbo1').val(user.cord1);
$('#cbo2').val(user.cord2);
$('#cbo3').val(user.cord3);
$('#cbo4').val(user.cord4);
});
});
Funny thing is when I put one alert
before completing the Combo, it works :)
Put your HTML and what’s in that JSON or it will be hard to help. Trying to guess, maybe this will help you? http://jsfiddle.net/0pdxwhx0/
– Sergio
Instead of putting an Alert, use the
console.log(...)
. This way it is easier to understand what happened because the synchronization problem will continue to occur. In addition, you could use presets and print the results in the events ofdone
,fail
andalways
.– EduardoFernandes
Hello Eduardo! The whole function is this ai...it returns 5 fields of php... What I realize is that he brings the data right, but give these bugs when filling the . val
– Rafael Spessotto
Dude, I don’t quite understand what you said...but you said it right. It’s some timing problem...
– Rafael Spessotto
@Rafaelspessotto what gives
console.log(JSON.stringify(data));
if you put it before the$.each
?– Sergio
Sergio returns normal BD data...but does not fill the combo with this information... :(
– Rafael Spessotto
@Rafaelspessotto you can show here what gives the
console.log(JSON.stringify(data));
? I have no idea what your JSON is like, and seeing it makes it easier.– Sergio