方法1:$(function(){ $.get("URL", function(Msg){ $("你要显示提示的地方").html("数据正在加载中。。"); $("你要显示查询数据的地方").html(Msg); }); }); 方法2:
<html><head> <title></title></head><body><input type="button" value="测试" onclick="ShowImg();" /><div id="div1"></div><div id="div2"></div></body></html><script type="text/javascript"> function ShowImg() { var div1 = document.getElementById("div1"); var div2 = document.getElementById("div2"); div1.innerHTML = "<img src=‘img/loaders/11.gif‘ />"; var t1 = setTimeout(function() { var img = new Image(); img.onload = function() { div1.innerHTML = ""; }; img.src = "img/pdf.png"; div2.appendChild(img); }, 3000); }</script> 方法3-- beforeSend进行设置:
模拟Toast效果
ajax请求服务器加载数据列表时提示loading(“加载中,请稍后...”),
$.ajax({
type: "post",
contentType: "application/json",
url: "/Home/GetList",
beforeSend: function () {
$("loading").show();
},
success: function (data) {
if (data == "Success") {
// ...
}
},
complete: function () {
$("loading").hide();
},
error: function (data) {
console.info("error: " + data.responseText);
}
});
时间: 2024-10-10 04:43:05