ajax的error方法参数说明及ERR_CONNECTION_REFUSED异常捕获

原文地址:https://www.cnblogs.com/fireporsche/p/6391061.html

error:function (XMLHttpRequest, textStatus, errorThrown) 

textStatus:"timeout", "error", "notmodified" 和 "parsererror"。


针对网络异常的net::ERR_CONNECTION_REFUSED错误,可以这样捕获

$.ajax(****).fail(function (jqXHR, textStatus, errorThrown) {
                //net::ERR_CONNECTION_REFUSED 发生时,也能进入
                console.info("网络出错");
                alert("网络异常:无法连接到服务器!");
            });

你可能感兴趣的:(ajax)