dongza1708 2015-04-03 11:32
浏览 843
已采纳

Javascript location.reload()丢失参数(空$ _GET)

If I am at page

test.php?parameter1=some&parameter2=some

and I execute the script

<script type="text/javascript">
        $(document).ready(function($) 
         {

                    //window.location.replace(window.location.href);
                    //window.location.href += "#mypara";
                    //location.href.reload();
                    location.reload();
        });
</script>

the location.reload() function loses any $_GET parameters (Notice I tried without any result using the window.location.replace() function).

It seems the location reload has the correct location.href with correct parameters but the request is sent to the server without $_GET set, by debugging with PhpStorm indeed I see no $_GET is set.

Searching on the internet I found no working solution to pass $_GET parameters when issuing location.reload().

  • 写回答

1条回答 默认 最新

  • dsq30861 2015-04-03 11:37
    关注

    Try with

    location.reload(true); //It load document from server
    

    If you write location.reload() then it will reloads the page from the cache.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?