更新时间:2023-12-05 10:39:52
由于 ajax
请求是 asynchronous
加载的显示并立即再次隐藏.使用 ajax
的 complete
回调来隐藏加载器.
As ajax
request is asynchronous
the loaded is shown and hid again immediately. Use complete
callback of ajax
to hide the loader.
检查下面突出显示的代码:
Check the highlighted code below:
$('#checkqar').on('click', function() {
$("#loading").css("display", "block");
$.ajax({
type: "GET",
url: "http://sss.com/eee",
crossDomain: true,
jsonpCallback: 'callback',
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
success: function(msg) {
//do something
},
complete: function() {
$("#loading").css("display", "none");
// Use it here
}
});
});