zoukankan      html  css  js  c++  java
  • Jquery 一次处理多个ajax请求的代码

    Jquery 一次处理多个ajax请求的代码,需要的朋友可以参考下。
     
    复制代码代码如下:

    $(document).ready(function () { 
    $('#getsetgo').click(function () { 
    $.when($.ajax("page1.php"), $.ajax("page2.php")).done(function(a1, a2){ 
    $('#id1').html(a1[0]); 
    $('#id2').html(a2[0]); 
    }); 
    }); 
    }); 

    jquery 1.5发布后,其中新增加方法jQuery.when().可以一次处理多个ajax请求。更多详细情况查看jquery api文档。 
    Collection by Ancker

    jquery 同一个页面处理多个ajax请求的另外一种方法 
    加一个参数 
    复制代码代码如下:

    $.post( 
    "doSysthFile.aspx", 

    type: '1' 
    }, 
    function(data, textStatus) 

    }, 
    "json"); 
    $.post( 
    "doSysthFile.aspx", 

    type: '2' 
    }, 
    function(data, textStatus) 

    }, 
    "json"); 

    在doSysthFile.aspx.cs文件中: 
    复制代码代码如下:

    if ((!string.IsNullOrEmpty(Request["type"])) && (Request["type"] == "1")) 

    //do something 

    if ((!string.IsNullOrEmpty(Request["type"])) && (Request["type"] == "2")) 

    //do something 

    这个不同的ajax就可以请求同一个页面处理了,不需求为每个ajax请求建立一个新的页面
  • 相关阅读:
    AcWing 204. 表达整数的奇怪方式 / Strange Way To Express Integers
    Codeforces Edu Round 67 A-C + E
    Codeforces Edu Round 66 A-E
    Codeforces Edu Round 65 A-E
    Codeforces Edu Round 64 A-D
    Codeforces Edu Round 63 A-E
    Codeforces Edu Round 62 A-E
    Codeforces Edu Round 61 A-C + F
    python 线程池和锁
    python 线程
  • 原文地址:https://www.cnblogs.com/libin-1/p/5895951.html
Copyright © 2011-2022 走看看