Angularjs: how to make fire and forget with $ http

I need to make a mail request in which I am not interested in the answer (Fire And Forget)

I found a way to do this

xhr.onreadystatechange = function() { xhr.abort(); }

source

But in angular everything is a little different. For example, when using$http

var promise = $http.post(url, data);

I do not see how I can get the object xhr? Any suggestions?

+3
source share
2 answers

Alternatively, you can use the timeout parameter on $ http to cancel the request.
Starting with AngularJS v.1.1.5, you can even use the promise to abort the request:

var defer = $q.defer();
$http.get('/example', { timeout: defer.promise }).success(callback);
// [...]
defer.resolve();
+3
source

, , ? http- $http.post(url, data), (, true).

+2

All Articles