-1

I'm trying to redirect to a new URL using window.location.href which does not seem to work for a particular URL.

The page URL is: http://localhost:37368/Office/Search/c2VhcmNoaWRzPTEyMiwxMjIsMTI0LDE1OCwzNzl8bG9jYXRpb25pZHM9MSwyfGZyb21pZHM9fHRvaWRzPQ==

Upon a button click, something happens using an AJAX post, and the URL is changed, via JavaScript, to http://localhost:37368/Office/

However, the page always redirects back to the previous one.

The JS code:

onClear: function (event) {
    //.... omited for purpose of question

    var $controller = (event.data.object.settings.controller === undefined) ? '' : event.data.object.settings.controller
        $new_url = window.location.protocol + '//' + window.location.host + '/' + $controller;

    window.sessionStorage.clear();            
    window.location.href = $new_url;
}
JadedEric
  • 1,943
  • 2
  • 26
  • 49

1 Answers1

0

Try to add to new URL some random parameter to avoid caching or other bugs:

$new_url = window.location.protocol + '//' + window.location.host + '/' + $controller + '?r=' + ("" + Math.random()).substr(2, 4);
Somerussian
  • 381
  • 4
  • 17