手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery实现ajax加载超时提示的方法
jquery实现ajax加载超时提示的方法
摘要:本文实例讲述了jquery实现ajax加载超时提示的方法。分享给大家供大家参考,具体如下:index.php加载超时functionload...

本文实例讲述了jquery实现ajax加载超时提示的方法。分享给大家供大家参考,具体如下:

index.php

<!doctype html> <html> <head> <meta charset="utf-8"/> <title>加载超时</title> <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7/jquery.min.js"></script> </head> <body> <script type="text/javascript"> function load(){ $("#tips").html("加载中..."); $.ajax({ async:true, cache:false, timeout:8000, type:"POST", url:"result.php", data:{a:'123'}, error:function(jqXHR, textStatus, errorThrown){ if(textStatus=="timeout"){ $("#tips").html("加载超时,请重试"); }else{ alert(textStatus); } }, success:function(msg){ $("#tips").html(msg); } }); } </script> <input type="button" id="load" value="点击加载"/> <div id="tips"></div> </body> <html>

result.php

<?php //sleep(20); sleep(2); echo $_POST['a'].'test服务器返回结果';

希望本文所述对大家jQuery程序设计有所帮助。

【jquery实现ajax加载超时提示的方法】相关文章:

基于jquery实现下拉框美化特效

javascript实现点击后变换按钮显示文字的方法

javascript实现模拟时钟的方法

js实现两点之间画线的方法

JS实现兼容各浏览器解析XML文档数据的方法

js获取滚动距离的方法

javascript实现点击商品列表checkbox实时统计金额的方法

jquery简单实现外部链接用新窗口打开的方法

js实现鼠标移到链接文字弹出一个提示层的方法

js+HTML5实现canvas多种颜色渐变效果的方法

精品推荐
分类导航