Ajax 代码,用于在网页未加载时显示注释/信息框



我有下面的代码,

<script>
    function AjaxLoadFWs() {
        var sPath = window.location.pathname;
        var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
        $('#overviewfw').load("http://test.com/test.asp");
        change_overview();
        change_overview_detail();
    }
</script>

现在,如果http://test.com/test.asp在10秒内未加载。

需要添加什么代码?

.load()调用是.ajax()的一种方便简写。由于您想要10秒的timeout,我建议使用ajax,因为它提供了更多选项:

$.ajax('http://test.com/test.asp', {
   timeout: 10000, // 10 seconds
   success: function(data, textStatus, jqXHR) {
      //here you have to process the data you get
   },
   error: function(jqXHR, textStatus, errorThrown) {
      //here you can handle the timeout.
   }
});

最新更新