javascript - JavaScript 在 XHR 中的 this.response 中不起作用
问题描述
我今天对这段代码有两个问题:
document.addEventListener('click', function(event) {
if (event.target.tagName !== "A" || !event.target.href) return;
event.preventDefault();
document.body.style.opacity = 0
var res = new XMLHttpRequest();
res.addEventListener("load", function() {
document.querySelector('html').innerHTML =
this.response;
});
res.open("GET", event.target.href);
res.send();
});
如何插入动画document.body.style.opacity = 0;
和document.body.addEventListener("transitionend", function() {
(现在它不起作用)
为什么不是this.response;
不读JS的结果?(页面加载没有 JS)。
解决方案
推荐阅读
- c# - 从 C# 连接到 Docker 实例中的 SQL 数据库失败
- python - 如果模式存在,则在python中提取子字符串
- python - prepopulated_fields 导入数据库时不会触发
- php - 使用 laravel 使用 ajax 调用请求未定义
- javascript - 烧瓶 api 和 javascript 的 CORS 问题
- python - 数据框应用方法未更新所有行
- java - 发现无效的 Gradle JDK 配置。在 Android Studio 中打开 Gradle 设置更改 JDK 位置而 JDK 在任何地方都找不到
- java - 在 Glassfish-Netbeans 中找不到 Java 资源文件
- powershell - 如何以非管理员用户身份运行“Get-CimInstance”(windows server 2019,powershell 5.1)
- javascript - Reactjs-如何将数据或变量从一个组件传递到另一个组件