html - 在没有页面加载的情况下在 jQuery 中加载页面
问题描述
正如我们所知,react 不会在单击锚点时加载窗口。这就是为什么响应网络应用程序很快。我想要 jQuery 中的相同功能。我想在 Jquery 中加载页面而不加载页眉、页眉和页脚。我该怎么做?我什至不知道我能不能做到。
$(document).on("click", function (e) {
let anchor = $(e.target);
var url = anchor.attr("data-url-redirect");
if (e.target.nodeName == "A") {
// console.log(anchor, url);
$.ajax({
url: url + '.html',
success: function (result) {
$(".pageWrapper").html(result);
console.log(result, url);
if (history.pushState) {
var newurl =
window.location.protocol +
`//` +
window.location.host +
window.location.pathname +
"/" +
url;
window.history.pushState({ path: newurl }, "", newurl);
}
},
});
}
});
});
这是我写的代码。我可以加载页面并更改 URL。但是当我刷新分页符时。请让我知道是否可以使用 jQuery。如果有可能,那么我该如何实现呢?
解决方案
推荐阅读
- c# - 如何使用选择排序按三个不同的方面排序
- python - 将参数传递给数据类会导致 TypeError
- aws-lambda - AWS Lambda 函数处理程序响应以打开深层链接
- javascript - 用 JS 删除 html 元素
- javascript - 获取请求 response.json() 返回未定义
- python-3.x - 将小数点放在数据框列中的正确位置
- security - Kerberos 预身份验证失败
- java - 通过 ActiveAndroid 选择不同的行
- c# - C#9 顶级语句文件上的属性
- python - Python hex/int/bin 转换器抛出错误