我有一个index.html页面,其中我有一个使用
XMLHttpRequest通过
Javascript运行PHP代码的按钮.
解决方法
添加到
Jesse’s answer:
You only have to rename the page to
.PHP
if there is PHP code on that page that needs to be executed. If that is not the case,you can leave it as.html
.
此外,请确保您没有为.html文件启用缓存,因为通常,作为一个静态文件,AJAX往往会获得它的缓存版本.您可以通过两种方式禁用AJAX缓存:
使用XHR的缓存:
xhr.setRequestHeader('Cache-Control','no-cache');
或者,附加查询字符串:
xhr.open('GET','file.html?cachebuster=' + new Date().getTime());
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。