Hi, I've got following code: var tr; function updateNummbers(typ) { var ret = "";
$.ajax({ type: "POST", url: "DFWebService.asmx/getNummbers", dataType: "text", data: "typ=" + typ, processData: false, error: function(XMLHttpRequest, textStatus, errorThrown) { ajaxError(XMLHttpRequest, textStatus, errorThrown); }, success: function(xml) { ret = $(xml.replace(/</g, "<").replace(/>/ g, ">")).find('anzahl').text(); tr = ret; alert(tr); // OK alert(ret); // OK } }); alert(ret); // VALUE "" } updateNummbers('new'); alert(tr); // NO VALUE it is placed in $(document).ready( function() { I don't know why the value of updated variable tr outside function updateNummbers don't exists. In alert inside this function value is ok, but then I put alert after the function values are not correct. The same situation is for variable ret. Can anyone explain that to me?