jquery - jQuery hide() 函数不适用于警告框
问题描述
我在 ajax 调用期间遇到了 jQuery hide 方法的问题。
当 ajax 方法启动时,加载器 div 会正确显示,但在成功(或错误)方法中,加载器 div 仅在警报框关闭后才会隐藏。
$.ajax({
type: 'GET',
url: 'ajax/myfile.php',
dataType: 'json',
data: {'id':id, 'message':message},
beforeSend: function() {
// Show image container
$("#loader").show();
},
success: function(result, textStatus, jqXHR) {
$("#loader").hide();
alert(result.message);
},
error: function(jqXHR, textStatus, errorThrown) {
$("#loader").hide();
//Display the error.
alert(textStatus+': '+errorThrown);
}
我该怎么做才能使加载程序 div 立即隐藏?
解决方案
推荐阅读
- moodle - 重新申请课程完成标准
- apache - 如何配置 Bitnami Lightsail LAMP 服务器来托管第二个网站?
- java - 如何按位运算?(运算符 & 不能应用于 Integer 或 int)
- docker - 部署的 Docker-Compose 返回“502 Bad Gateway”
- javascript - C3JS - 有没有办法在仪表图上动态更新 color.threshold 值?
- algorithm - 以下方法的时间复杂度是多少?
- inheritance - 如何为一种类型实现多个特征并在特征之间进行选择?
- linux - Bluez 5.50 Gatt 服务器终止后的 D-Bus 连接错误
- r - 在 Shiny 中按日期范围计算平均值和中位数
- azure-ad-b2c - 当我尝试使用 trustFrameWork API 更新 B2C 策略时,$value 应该是什么?PUT /trustFramework/policies/{id}/$value