2013-04-05 90 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) {}}); 
相关问题