Abort HTTP request when redirect

453 views Asked by At

I got this page which uses Angular and when the page is loaded, it requests some data from a HTTP get call. My problem is that if the user navigates to a other page while the HTTP get call is going on, the system gives a error and then gives me the HTTP error callback showing the alert with "Error".

$http.get('/api/something/).success(function (data, status, headers, config) { 
        alert(data);        
}).error(function (data, status, headers, config) {
        alert('Error');
    });

What I want instead is to just abort the http call and then move the user to the other page without the error function being called.

So far I found this.

But I can't see how I can use it to fix my problem.

0

There are 0 answers