javascript - 除了使用警报功能外,我如何在 ajax 中打印警报消息
问题描述
除了使用警报功能外,我如何在 ajax 中打印警报消息。
if (x.readyState == 4 && x.status == 200)
{
var msg=x.responseText.trim();
if(msg=="Thank you for booking and Have a nice Journey!!!")
{
alert("Successfully submitted");
window.location="home.html";
}
}
解决方案
这是代码示例:
function displayAlertMessage(message) {
var timeOut = 5
jQuery('#messageBox').text(message).fadeIn()
jQuery('#messageBox').css("display", "block")
setTimeout(function() {
jQuery('#messageBox').fadeOut()
jQuery('#messageBox').css("display", "none")
}, timeOut * 1000);
}
messageBox 是您要在其中显示警报消息的 div 标签的 id。timeOut 是您希望在屏幕上保留消息的秒数。
推荐阅读
- graphviz - 强制子图之间的边向左或向右
- git - Github Actions - 我如何使用私有模板仓库创建子文件夹
- facebook-opengraph - 来自调试器的 og:url 不等于来自 html 代码的 og:url
- c - 多个线程中只有一个正在写入
- azure - 使用 API 获取 Azure 服务主体应用程序级别权限
- android - LiveData 的竞争条件
- javascript - 在 next/react 组件中实现页面 javascript
- javascript - 如何通过替换原始数组来替换另一个数组中的唯一值
- html - NGINX html 格式错误
- javascript - Node.js | 将端点转换为通用路径以在 YAML 文件中匹配