ajax 的error参数

ajax发生错误会进入到error中,我们在这里把错误信息从控制台中输出出来,为了避免每次写ajax都得写好几个console.log()。

我在这里写一个模板,需要用的时候直接过来拷贝。

                        error : function(jqXHR, textStatus, errorThrown) {
                            /*输出jqXHR对象的信息*/
                            console.log(jqXHR.responseText);
                            console.log(jqXHR.status);
                            console.log(jqXHR.readyState);
                            console.log(jqXHR.statusText);
                            /*输出其他两个参数的信息*/
                            console.log(textStatus);
                            console.log(errorThrown);
                        }

猜你喜欢

转载自www.cnblogs.com/liujinming/p/10615085.html