我写我的服务器(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秒后仍然没有改变。
是否与此服务器相关?或者我的代码有问题? 请帮助
,像变魔术一样,谢谢你 –