Cancel DoJo XHR-Request

I am using the dojo / request / xhr module for HTTP requests.
Is it possible to abort the active request as possible using XMLHttpRequest ?

Thanks in advance, Frank

+3
source share
1 answer

The promise returned by dojo/request/xhr has a cancellation method (for example, normal promises) that aborts the HTTP request.

 var request = xhr("foo/bar").then(someHandler, someErrorHandler); ... if(!request.isResolved()) { request.cancel(); // aborts request and triggers the error handler } 

Example here: http://fiddle.jshell.net/QgWNA/

+3
source

Source: https://habr.com/ru/post/970927/


All Articles