Check if connected to a network; jQuery

后端 未结 7 1020
执笔经年
执笔经年 2020-12-13 20:37

I have searched through StackOverflow and have seen various topics on how to do this, but nothing that really pertains to my particular situation. I am writing (for a class)

7条回答
  •  死守一世寂寞
    2020-12-13 21:04

    try to set up ajaxSetup to do a request every n milliseconds (i put 1000 here) and check if it times out and then disable button.

    $.ajaxSetup({
        timeout: 1000, 
        error: function(request, status, maybe_an_exception_object) {
            if(status != 'timeout')
                //Code to enable button
            else
                 //Code to disable button
        }
    });
    

提交回复
热议问题