隔江千里
ajax是异步的你不能直接获取result的值第一种用回调函数获取function sendFilePost(url, data,successCb,failCb) { $.ajax({ type: "POST", url: basePath + url, data: data, //async: false, cache: false, contentType: false, processData: false, }).done(function (res) { successCb(res) }).fail(function (res) { failCb(res) });}//调用sendFilePost(url,data,function(res){},function(res){})第二种直接把ajax返回出去function sendFilePost(url, data) { return $.ajax({ type: "POST", url: basePath + url, data: data, //async: false, cache: false, contentType: false, processData: false, })}//调用sendFilePost(url,data).done(function(res){}).fail(function(res){})