var msg=0; Validater('abc'); function Validater(Name) { var itemId = 1; $.ajax({ url: 'adminmenu/ValidaterMenuName/', type: 'POST', cache: false, data: { Name: encodeURIComponent(Name),ID:itemId }, dataType: 'text', async: false, timeout: 1000, error: function () { alert('Error'); }, success: function (result) { msg=result;//此处是无法给msg赋值的 GetNumber(result);//调用成功后 把值传递给别的函数,否则获取不到msg的值 } }); } function GetNumber(number) { msg = number; }