Refresh page after onclick in

后端 未结 3 419
长发绾君心
长发绾君心 2020-12-20 01:07

I have the following code:

\');\" name=\"remove[]\"          


        
相关标签:
3条回答
  • 2020-12-20 01: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>
    
    0 讨论(0)
  • 2020-12-20 01:16

    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(); });

    0 讨论(0)
  • 2020-12-20 01:20

    First answer is correct, also you could use

     window.location.reload();
    
    0 讨论(0)
提交回复
热议问题