getJSON timeout handling

后端 未结 6 1001
借酒劲吻你
借酒劲吻你 2021-02-12 10:36

I am using jQuery getJSON() function. This function getting data with no problem. But sometimes waiting, waiting waiting... And my loading bar showing loading loadi

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-12 11:04

    There's always the nuclear route as well:

    //Set AJAX timeout to 10 seconds
    $.ajaxSetup({
      timeout: 10*1000
    });
    

    This will set all the AJAX requests your program makes (even via $.getJSON) to have a time out of 10 seconds (or what have you).

提交回复
热议问题