[英]Cache the results from the ajax calls to prevent running them multiple times
In my project i have a php file that launch a js function that make an ajax call. 在我的项目中,我有一个php文件,该文件启动js函数以进行ajax调用。 My problem is, if a user refresh php page on browser function re-make ajax call and so on. 我的问题是,如果用户刷新浏览器功能上的php页面,请重新进行ajax调用,等等。 I need to cache the first result of ajax execution so that if the refresh is done being used data in the cache and not the ajax call is made again. 我需要缓存ajax执行的第一个结果,以便在刷新完成后使用缓存中的数据,而不是再次进行ajax调用。
My call is 我的电话是
if (xmlHttp)
{
// try to connect to the server
try
{
xmlHttp.open("GET", "top10.php?P1="+oStxt, true);
xmlHttp.onreadystatechange = handleRequestStateChange10;
xmlHttp.send(null);
}
// display the error in case of failure
catch (e)
{
alert("Can't connect to server:\n" + e.toString());
}
How can i prevent multiple ajax call from browser page refresh? 如何防止浏览器页面刷新多个Ajax调用?
Thanks in advance 提前致谢
I would suggest the following flow: 我建议以下流程:
Easy! 简单!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.