function getSSOUrl(urlvalue) { var urls; $.ajax({ type: "GET", url: "../../GeoManage/TBL__PROJECTINFO/GetUrl?urlvalue=" + urlvalue, success: function (data) { urls = data; } }) return urls; } 这样写success里面的urls 有值,但是下面return urls;确没有值,修改如下 加上一句async: false, //同步请求就可以了 function getSSOUrl(urlvalue) { var urls; $.ajax({ type: "GET", url: "../../GeoManage/TBL__PROJECTINFO/GetUrl?urlvalue=" + urlvalue, async: false, //同步请求 success: function (data) { urls = data; } }) return urls; }