Javascript 我被迫刷新文件(html)后,fwrite显示的变化

Javascript 我被迫刷新文件(html)后,fwrite显示的变化,javascript,php,fwrite,Javascript,Php,Fwrite,总体视图: $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.solut

总体视图:

   $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;
我正在服务器()上的一个文件中编写一个简单的html表,然后将文件url返回到Javascript 使用ajax在新选项卡中打开。这是我的代码:

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:

   $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;
$.ajax({
url:“index.php?route=sale/print/printStock&token=”,
类型:“post”,
数据:{ids:ids},
cache:false,
}).完成(功能(数据){
//使用php中的url,我在这里打开了一个新选项卡
打开(数据“U空白”);

});很可能是浏览器缓存,而不是“旧”文件。请尝试更改url:

echo "http://www.webber.solutions/stock_order.html?t=".time();

或者类似于避免缓存的内容

很可能是浏览器缓存,而不是文件“旧”尝试更改url:

echo "http://www.webber.solutions/stock_order.html?t=".time();

或者类似于避免缓存的方法,您可以在打开如下窗口后刷新页面:

$.ajax({
    url: "index.php?route=sale/print/printStock&token=<?php echo $token; ?>",
    type: "post",
    data: {ids:ids},
    cache: false,
    }).done(function( data ) {
       // using url from php i open a new tab here
    window.open(data , '_blank');
    document.location.reload(true);
    });
$.ajax({
url:“index.php?route=sale/print/printStock&token=”,
类型:“post”,
数据:{ids:ids},
cache:false,
}).完成(功能(数据){
//使用php中的url,我在这里打开了一个新选项卡
打开(数据“U空白”);
文档。位置。重新加载(true);
});

打开如下窗口后,您可以刷新页面:

$.ajax({
    url: "index.php?route=sale/print/printStock&token=<?php echo $token; ?>",
    type: "post",
    data: {ids:ids},
    cache: false,
    }).done(function( data ) {
       // using url from php i open a new tab here
    window.open(data , '_blank');
    document.location.reload(true);
    });
$.ajax({
url:“index.php?route=sale/print/printStock&token=”,
类型:“post”,
数据:{ids:ids},
cache:false,
}).完成(功能(数据){
//使用php中的url,我在这里打开了一个新选项卡
打开(数据“U空白”);
文档。位置。重新加载(true);
});