jquery - 重定向时如何修复从查询字符串中检索到的消失的特定数据
问题描述
我正在我的网站上设置搜索,问题是,当设置查询字符串然后重定向到搜索页面时,检索到的 json 数组消失并且永远不会回来。
整个网站运行在带有 Bootstrap 4 框架的 node.js 服务器上。我还尝试过的是,在加载搜索页面时,请求整个数据库,但这会降低网站的性能。
function setqstring() {
var input= $("input")[0].value;
$(document).ready(() => {
window.location.replace('http://localhost/search/search.html?q='+ input)
$.getJSON('/action/search?q=' + GetURLParameter, function(data) {
console.log(data);
});
});
}
我希望,当设置查询字符串时,该页面会将我重定向到搜索页面,然后服务器会为我提供要使用的特定 json 数组。