mardi 23 février 2016

What would be the best way to change the URL and load a new page with an AJAX get response?

The reason I'm doing this with an AJAX request is because I need to make some custom header for an authentication token, as a simple redirect would have worked otherwise.

var config = {headers:  {
        "jwtToken" : sessionStorage.getItem('jwtToken')
    }
};

var successCallback = function(response) {
    console.log(response.data);
    window.document.write(response.data);
};

var errorCallback = function(response) {
    $location.path('/error');
    console.log(response);
    console.error('/app/graphs GET failed');
};

Right now the response is getting written to the document but the URL does not change to what I need it to. Also, I'm not entirely sure if this is a good way to do it.

Essentially my question is asking for the proper way to use an AJAX request to load an entire page while changing the URL to the one the AJAX get request was sent to.




Aucun commentaire:

Enregistrer un commentaire