我使用ajax动态获取数据,但存在问题。当我刷新页面时,获取的数据会丢失。我想刷新页面后数据保持不变。从ajax提取数据后重新加载页面
想这是我的网页:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
/* fetching data which matches the keyword*/
function Search()
{
$.post("search.php", {search_word: $('#searchInput').val()} , function(data){
if(data){
$('#results').show();
$("#results").append(data);
}
});
}
</script>
</head>
<body>
<input type="text" value="" id="searchInput"/>
<input type="button" value="Search" onclick="Search();"/>
<div id="results" style="display:none"></div>
</body>
</html>
当我上的搜索按钮,点击它排在结果DIV刷新页面后,就会消失的数据。
您应该向社区提供一些您的代码,以便我们可以看到您要做的事情并为您提供详细的帮助。 – sirmdawg
假设有一个div的id为demoDiv,并且来自搜索页面的响应数据出现在这个div中,现在当我刷新页面时,这个div数据将消失...但我希望在重新加载页面后数据将保留在此处。 。这对你来说是可以理解的,现在我的问题是什么? –
是的,你可以编辑你的问题,包括你使用的示例代码?也许阿贾克斯加载部分? – sirmdawg