cache.html ------- 靜態頁面<html> <script type="text/javascript">
$(function(){
$.post("server.php",{flag:1},function(ev){ if (ev.code==1) {
$('p').append(ev.msg)
}else{
$('p').append(ev.msg)
}
},'json')
}) </script><body>
<p></p> </body> </html>static.php ---------PHP代碼<?php
$file = "cache.html";
$expr = 60; if(file_exists($file)) {
$ctime =filectime($file); if($ctime+$expr > time()){ //判斷是否過期
echo file_get_contents($file);
}else{
unlink($file);
ob_start(); include('static.html');
$content = ob_get_contents();
file_put_contents($file,$content);
ob_end_flush();
}
}?>執行static.php時 調用靜態頁面可以執行ajax程序 為什么 我單獨打開cache.html時ajax沒有執行?請問這是為什么呢
為什么單獨點擊靜態頁面,不執行AJAX程序?
aluckdog
2018-10-17 13:10:41