$.when( /** * 今日注册用户数 */ $.get("/user/register/count/today", function (data) { $(".todayRegister span").text(data.count); } ), /** * 今日登录用户数 */ $.get("/user/login/count/today", function (data) { $(".todayLogin span").text(data.count); } ), /** * 系统用户数 */ $.get("/user/stat", function (data) { $(".userAll span").text(data.count); } ), /** * 图片总数 */ $.get("/up/stat", function (data) { $(".imgAll span").text(data.count); } ) ).done(function () { /** * 数字格式化 */ $(".panel span").each(function () { $(this).html($(this).text() > 9999 ? ($(this).text() / 10000).toFixed(2) + "<em>万</em>" : $(this).text()); }) }).fail(function () { layer.msg("系统正在开差中呢~~~~", {icon: 5}); });
$.when里面的异步请求都完了之后,再执行done里面的函数