单击

时间:2017-07-01 14:17:21

标签: javascript

我创建了一个脚本,其中onclick加载了一个url的父目录。这个父目录应该每次都自动刷新并给出一个新的结果,但它不会在现场运行。虽然在本地就可以了。

链接每次都会随机加载数据库中的条目,例如: https://whereshouldieat.ie/restaurant/Burger/

<input type="button" class="btn-primary" value="Choose somewhere else!" onClick="window.location.href=window.location.href = '../<?php print $restaurant->food_type ?>/'; //one level up">

每次单击此按钮都会因类而创建新结果。它在localhost上工作正常,但在实时使用时结果保留了原来的结果,而不是刷新到/ restaurant / burger的新结果

我正在使用cloudfare CDN我不确定这是否会影响它。

我怎样才能让它在现场工作?有没有比这更好的方法:

onClick="window.location.href=window.location.href = '../<?php print $restaurant->food_type ?>/'; //one level up">

1 个答案:

答案 0 :(得分:0)

我已将一段代码添加到脚本的末尾

?nocache=' + (new Date()).getTime()

这意味着网站/服务器缓存不会继续提供相同的链接。但现在在网站的末尾有一个字符串,如:

https://whereshouldieat.ie/restaurant/Burrito/?nocache=1498920656723