[removed].reload not working for Firefox and Chrome

前端 未结 8 511
灰色年华
灰色年华 2020-12-08 15:44

I want to change the user status on click of a Button, so all I am doing is, detecting the current status and changing, if needed.

But in this case the changes the s

相关标签:
8条回答
  • 2020-12-08 16:08

    Mega solution I just have found.

    You have to simulate to post an empty form.

    HTML

    <form id="myForm" action='@Url.Action("Details","Main", new { id = @Model.ID } )'></form>
    

    JS

    document.getElementById("myForm").submit();
    
    0 讨论(0)
  • 2020-12-08 16:12

    I had the same issue in Chrome and Firefox. I was able to alleviate the issue by having the server respond with the url of the page. For your case you could have the response be the new value for the user status. Here are two examples:

    $.post('?action=' + myAction, function (data) {
            window.location.href = data;
        });
    

    ..and the server response

    Response.Write("/yourUrl);
    Response.End();
    

    This eliminated the inconsistency in Chrome and the page reloads without fail.

    0 讨论(0)
  • 2020-12-08 16:13

    I had this problem in AngularJS and in Firefox. (Reloading was fine in Chrome). By using setTimeout problem solved.

    setTimeout(function(){
      window.location.reload();
    });
    
    0 讨论(0)
  • 2020-12-08 16:17

    Have you tried this?:

    window.location = window.location;
    

    Apparently you can drop the "window.", but haven't tried it myself.

    0 讨论(0)
  • 2020-12-08 16:18

    Look this You can force the the reload to get the page from server by setting the forceGet parameter to true:

    location.reload(true);
    
    0 讨论(0)
  • 2020-12-08 16:26

    I have two other options to you:

    history.go(0);
    

    And:

    window.location.href = window.location.href;
    

    I'm not tested it on Firefox and Chrome yet, but it may help you faster. Tomorrow I'll do the tests and update the answer if this not work.

    0 讨论(0)
提交回复
热议问题