<script> var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://www.liulongbin.top:3006/api/getbooks'); //超时的时间(毫秒数) xhr.timeout = 2000; //超时的回调函数 xhr.ontimeout = function () { alert('请求超时') } xhr.send(); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { console.log(xhr.responseText); } } </script>
正文
XHR Level2新特性-HTTP请求时限
转载请注明出处:米耀华博客
还没有评论,来说两句吧...