Refresh page after onclick in <a></a>

女生的网名这么多〃 提交于 2019-11-29 12:05:08

To reload the page using javascript you can do:

window.location.href=window.location.href

So to reload after the onclick simply add that to the end of onclick, eg:

onclick="removeCart('<?php echo $product['key']; ?>');window.location.href=window.location.href;"

edit: full code with delay

<a onclick="removeCart('<?php echo $product['key']; ?>');setTimeout('window.location.href=window.location.href', 100)" name="remove[<?php echo $product['key']; ?>]"  class="button"><span>Remove</span></a>

First answer is correct, also you could use

 window.location.reload();

you can resubmit the page to itself by triggering the submit of an input field for instance. Assuming that your hyperlink got the id nextLink and you got an input with id submitMe you can do :


 $("#nextLink").click(function () {
//setting the url of the action target (your page or controller) $('#submitMe').attr('action', '/MySection/MyPage.php'); $("#submitMe").submit(); });
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!