In a test , Request background datagram net::ERR_CONNECTION_REFUSED
Error of . The reason why I failed this time is because of the wrong address . There are many reasons for this problem ,1, It could be the Internet 2, It is possible that the request address is wrong
…. The root cause of this mistake is that ajax request was aborted ;

The landing function test done at that time , The response on the page is after clicking login , There was no reaction , The user experience is very bad

In the face of this situation , If ajax Make another level of judgment when asking , stay ajax In case of unsuccessful request , Give failure prompt , The experience will be better

The specific optimization code is as follows :

The first one : Listen to the failed ajax request , The disadvantage is that there is no event specific , May bring bad effect

$(document).ajaxError(function(){
        alert(" Request error !");
    });

The second kind : For individual ajax Request a judgment of success or failure

$.ajax({
                url:"system/login/login.action",
                timeout:6000,
                success:function(data){}
         }).done().fail(function(){
                alert(' The Internet doesn't work , Request error ')
            })
 

Technology
©2020 ioDraw All rights reserved
Sharing a script of hacker empire code rain , Simple and fun !-bash The Trojan horse , Have you ever met one ?k8s delete pod Zhejiang University data structure midterm examination questions Detailed explanation PHP Medium die,exit,returnlayui.table Examples of dynamically getting header and list data Interview questions : Handwritten list ( Include reverse linked list ) After the outbreak Which programming has a bright future PTA Quick sort Ctrip 2019 School recruitment LRU Cache