[jQuery] Help with trigger() problem

[jQuery] Help with trigger() problem


Hey guys, I have a problem, Im trying to alert a value that is set
after a trigger is .. triggered but for some reason the order of my
commands doesnt seem to be happening properly....heres an example of
my code ...
I have a function assgined to everytime a select box changes.
$("#select").change(function() {
$(":text").val("");
$.post("request.php",{q:this.value},function(data){
$("#nombre").val(data.nombre);
$(":text").attr('readonly', "readonly");
},"json" );
});
//and I have this code that triggers it further along the program
$("form").submit(function(){
x=true;
select.children().each(function() {
if((($
(this).val())==(cedula.val()))&&(select.attr("selectedIndex")==-1))
{
x=false;
var ced=cedula.val();
$("option[value="+ced+"]").attr('selected',
"selected").parent("#select").trigger('change');
alert($("#nombre").val()+"is already registered");
select.removeAttr('disabled').fadeIn('slow');
}
});
return x;
});
For some reason, the #nombre textbox is being updated AFTER return x,
so it always (by always I mean everytime it passes that "if" that will
set x to false and alert the error, of course) alerts: "is already
registered".... without the name..... why is that??? ... thanks in
advance.