How to detect if a request was aborted?

后端 未结 4 1124
既然无缘
既然无缘 2020-12-03 02:54

I am making a request and then right after it I abort.

var x = $.get(url, function (d, e, xhr) { alert(d); });
x.abort();

The problem is th

4条回答
  •  隐瞒了意图╮
    2020-12-03 03:17

    This is by design. Test if data is null to determine if the request responded correctly.

    If a request with jQuery.get() returns an error code, it will fail silently unless the script has also called the global .ajaxError() method.

    It may be useful to handle this (from here).

提交回复
热议问题