Abort () triggers Error Undefined in chrome

I use the following code to access the request in race conditions:

if (currentAjaxRequest !== null) { currentAjaxRequest.abort(); } var query_string = getQuery(); currentAjaxRequest = $.get(query_string, function(data, textStatus, xhr) { if (xhr.status) { currentAjaxRequest = null; // do stuff } }); 

I noticed that in Chrome, when an error occurs when calling abort, it appears in the javascript console:

GET undefined (undefined)

This does not seem to affect the script at all - everything continues to work fine. Do I have to do something to fix this? Or is it just how chrome reports an aborted ajax request?

thanks for the help

+4
source share
1 answer

You probably understood correctly how Chrome reports an aborted request. jQuery calls the XMLHttpRequest abort () method. A recommendation on how this method should be implemented from the W3C can be found here .

Step 6 of this process is to "set the error flag to true", therefore, although Chrome considers that there is an undefined error message because the error message was not set inside the request object.

+1
source

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


All Articles