读书人

jQuery中Ajax函数的超时处置

发布时间: 2012-11-23 22:54:33 作者: rapoo

jQuery中Ajax函数的超时处理
jQuery中进行Ajax请求的高级函数有$.get();$.post();
但这些函数不能对超时进行处理,要进行超时处理,必须用低层Ajax函数:$.ajax();
示例代码:

<html>  <head>    <script src="jquery-1.2.js"></script>    <script>      $(document).ready(        function () {          $.ajax({            url: "ajax.error.php",            timeout: 1000,            error: function (xmlHttpRequest, error) {              console.info(xmlHttpRequest, error);            }          });        }      );    </script>  </head></html>

读书人网 >Ajax

热点推荐