Thank you guys! I have made a slightly different logic, which seems to be working fine:
function zipSearch2(){ var zip = $j('input#zip_entry').attr('value'); alert('second '+validation); ........... ............ } function zipSearch(){ var zip = $j('input#zip_entry').attr('value'); $j.post("markers.php", { validate: zip}, function(xml){ var validation = $j.xml2json(xml, true); if(validation.zip[0].city !='na') { zipSearch2(); } else $j('#bad_zip').dialog('open'); }); } So, I am calling the main function zipSearch2 from the ajax callback part of the zipSearch(). Are there any potential synchronization pitfalls here i should be aware of?