我寫我的服務器(http://example.com/stock_order.html)在一個文件中一個簡單的HTML表格,然後返回文件的URL爲Javascript 使用AJAX在新tab.this開是我的代碼:
PHP:
$newfile = fopen($_SERVER['DOCUMENT_ROOT']."/stock_order.html","w+") or die("Unable to open file!");
$txt ='';
$txt .='Here i put table data';
fwrite($newfile, $txt);
fclose($newfile);
$link = "http://www.webber.solutions/stock_order.html";
echo $link;
個
JS:
\t $.ajax({
\t url: "index.php?route=sale/print/printStock&token=<?php echo $token; ?>",
\t type: "post",
\t data: {ids:ids},
\t cache: false,
\t }).done(function(data) {
// using url from php i open a new tab here
\t window.open(data , '_blank');
\t });
問題: 數據被正確地寫在文件中,但也有一些延遲,這意味着當重定向到HTML文件,文件內容是舊數據,新寫入的數據僅在手動刷新頁面時顯示。
我試圖把fwrite延遲1-2秒後仍然沒有改變。
是否與此服務器相關?或者我的代碼有問題? 請幫助
,像變魔術一樣,謝謝你 –