2013-04-05 87 views
0

我有一些ajax調用,我想添加處理程序的情況下出現錯誤。我發現「錯誤」處理程序,但不起作用,即當互聯網連接丟失。這些情況下是否有第二個處理程序?ajax錯誤處理程序時,互聯網連接丟失

$.ajax({ 
     type: "GET", 
     url: "dosomethink.php", 
     success: function (data) { 
     $('#abc').html(data); 
     }, 
     error: function (xhr, ajaxOptions, thrownError) { 
     alert(xhr.status); 
     alert(thrownError); 
     } 
    }); 
+0

怎麼你究竟排查失去互聯網連接? – 2013-04-05 22:58:43

+0

@ Thomas1703您可以使用超時解決連接丟失問題。 – Adrian 2013-04-06 01:01:00

+0

爲什麼不使用navigator.onLine或XHR請求? – Chris 2013-04-06 01:02:07

回答

0

如果你使用超時和錯誤方法

$.ajax({type: 'GET',url: '/controller/action',timeout: 15000,success: function(data) {},error: function(XMLHttpRequest, textStatus,errorThrown) {}}); 
相關問題