发布于 2017-03-06 01:56:01 | 143 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的jQuery示例,程序狗速度看过来!

jQuery javascript框架

jQuery是一个兼容多浏览器的javascript框架,核心理念是write less,do more(写得更少,做得更多)。jQuery在2006年1月由美国人John Resig在纽约的barcamp发布,吸引了来自世界各地的众多JavaScript高手加入,由Dave Methvin率领团队进行开发。


这篇文章主要介绍了jquery实现ajax加载超时提示的方法,涉及jQuery中load方法的ajax加载超时设置与提示信息处理技巧,需要的朋友可以参考下

本文实例讲述了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" onclick="load();" value="点击加载"/>
    <div id="tips"></div>
  </body>
<html>

result.php


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

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



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务