手机
当前位置:查字典教程网 >编程开发 >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加载超时提示的方法】相关文章:

js+html5实现canvas绘制圆形图案的方法

Jquery实现动态切换图片的方法

jquery实现用户打分评分特效

JavaScript实现点击文字切换登录窗口的方法

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

jQuery实现html表格动态添加新行的方法

JS实现屏蔽shift,Ctrl,alt等功能键的方法

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

javascript实现Table排序的方法

JS实现定时自动关闭DIV层提示框的方法

精品推荐
分类导航