欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery實現(xiàn)ajax加載超時提示的方法

 更新時間:2016年07月23日 10:41:53   作者:coder  
這篇文章主要介紹了jquery實現(xiàn)ajax加載超時提示的方法,涉及jQuery中l(wèi)oad方法的ajax加載超時設(shè)置與提示信息處理技巧,需要的朋友可以參考下

本文實例講述了jquery實現(xiàn)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服務(wù)器返回結(jié)果';

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jquery中Ajax用法總結(jié)》、《jQuery form操作技巧匯總》、《jQuery常用插件及用法總結(jié)》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴展技巧總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論