需求就是不能再进入页面时加载数据,只能在点击其中一个按钮时把数据加载呈现出来。具体效果如最下面的图。

1、前台页面

 <h1 class="title" id="" name="" onclick="GetData(1)">
概述 <span class="title_icon"></h1>
<div class="mc_list" id="div001" style="display: none"> </div>

2、ajax代码

 GetData(n){
$.ajax({
type: "get",
url: "GetDataHander.ashx?para=" + n + "&jbid=" + jbid,
dataType: "json",
success: function (data) {
$.each(data, function (idx, item) {
$("#div00" + n).empty();
$("#div00" + n).append("<span style='font-family:黑体;font-size:14pt;'>" + item.DisArticleInfo_Title + "</span></br>" + item.DisArticleInfo_Info + "<br/>");
});
}
});
}

3、ashx页面

  public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string para = context.Request["para"].ToString();
DataTable dt = new DataTable();
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
DataTable dt3 = new DataTable();
DataTable dt4 = new DataTable();
string str = string.Empty;
if (para == "")
{
dt = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and (DisArticleInfo_ArticleTypeId=24 or DisArticleInfo_ArticleTypeId=1)", " DisArticleInfo_ID desc").Tables[];
}
if (para == "")
{
dt = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and DisArticleInfo_ArticleTypeId=16", " DisArticleInfo_ID desc").Tables[];
}
if (para == "")
{
dt = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and DisArticleInfo_ArticleTypeId=2", " DisArticleInfo_ID desc").Tables[];
}
if (para == "")
{
dt = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and DisArticleInfo_ArticleTypeId=18 ", " DisArticleInfo_ID desc").Tables[];
dt1 = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and DisArticleInfo_ArticleTypeId=19 ", " DisArticleInfo_ID desc").Tables[];
dt2 = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and DisArticleInfo_ArticleTypeId=21 ", " DisArticleInfo_ID desc").Tables[];
dt3 = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and DisArticleInfo_ArticleTypeId=22 ", " DisArticleInfo_ID desc").Tables[];
}
if (para == "")
{
dt = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and DisArticleInfo_ArticleTypeId=8 ", " DisArticleInfo_ID desc").Tables[];
dt4 = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and DisArticleInfo_ArticleTypeId=9 ", " DisArticleInfo_ID desc").Tables[];
}
if (para == "")
{
dt = disbll.GetList(, " DisArticleInfo_DiseaseId=" + context.Request["jbid"] + " and DisArticleInfo_ArticleTypeId=4", " DisArticleInfo_ID desc").Tables[];
}
if (dt.Rows.Count > )
{
str =JsonConvert.SerializeObject(dt,new DataTableConverter());
if (dt1.Rows.Count > || dt2.Rows.Count > || dt3.Rows.Count > )
{
dt.Merge(dt1);
dt2.Merge(dt3);
dt.Merge(dt2);
str = JsonConvert.SerializeObject(dt, new DataTableConverter());
}
if (dt4.Rows.Count>)
{
dt.Merge(dt4);
str = JsonConvert.SerializeObject(dt, new DataTableConverter());
}
}
context.Response.Write(str);
context.Response.End();

4、页面效果如图

Ajax加载数据的使用的更多相关文章

  1. 一起学爬虫——如何爬取通过ajax加载数据的网站

    目前很多网站都使用ajax技术动态加载数据,和常规的网站不一样,数据时动态加载的,如果我们使用常规的方法爬取网页,得到的只是一堆html代码,没有任何的数据. 请看下面的代码: url = 'http ...

  2. Ajax 加载数据 练习 自我有些迷糊了,写的大概请谅解 ^ _ ^

    查询表的显示,查询显示如果不嵌入PHP代码的话,用ajax怎么实现?   <h1>显示数据</h1> <table width="100%" bord ...

  3. table+ajax加载数据

    //ajax加载notice $(function() { //${pageContext.request.contextPath}/ /** var res = [ {noticeTitle:'必答 ...

  4. Ajax加载数据后百度分享实例

    <script type="text/javascript"> //百度分享 function baidu_share() { var title_val = $(&q ...

  5. 前台ajax加载数据

    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script> <script sr ...

  6. ajax 加载数据前的刷新动画

    $(document).ready(function(){     $.ajax({        type:"get",        cache:false,        u ...

  7. Ajax 滚动异步加载数据

    第一种情况:单个div滚动 HTML <body> <!-- search start --> <div class="search" #if($m_ ...

  8. Bootstrap-Select 动态加载数据的小记

    关于前端框架系列的可以参考我我刚学Bootstrap时候写的LoT.UI http://www.cnblogs.com/dunitian/p/4822808.html#lotui bootstrap- ...

  9. Ext选项卡tabpanel切换动态加载数据

    鸣人不说暗话,来张图: 代码开始:(使用Ext,ajax加载数据,如果你们有好的方法也可以多多交流)var tabxsk = new Object(); //初始化 tabxsk.init = fun ...

随机推荐

  1. 拾遗:git pull 与 push 远程分支与本地分支顺序识别问题

    最后放置的都是数据最终到达的仓库分支名称 对于pull来说,是拉到本地,所以本地仓库分支名称写在最后 git pull [--force] [remote repo]:[my repo] 对于push ...

  2. 前端(五)—— a、img、list标签

    a标签.img标签.list标签 一.a标签 1.常用用法 <a href="https://www.baidu.com">前往百度</a> <a h ...

  3. Stack,ArrayDeque,LinkedList的区别

        本文首发于cartoon的博客     转载请注明出处:https://cartoonyu.github.io/cartoon-blog     这段时间把疯狂JAVA再看了一遍,发现Stac ...

  4. 深入分析Synchronized原理

    前言 记得开始学习Java的时候,一遇到多线程情况就使用synchronized,相对于当时的我们来说synchronized是这么的神奇而又强大,那个时候我们赋予它一个名字“同步”,也成为了我们解决 ...

  5. Springboot循环依赖

    背景 最近在使用Springboot做项目的时候,遇到了一个循环依赖的 问题.那什么是循环依赖呢,常见的一种情形就是在ServiceA中注入了ServiceB,在ServiceB中也注入了Servic ...

  6. Boost.Interprocess

    https://github.com/svebert/InterprocessMsg 好像消息队列

  7. ajax--getJSON

    penson.json [ { "name":"张三", "age":25, "sex":"男", ...

  8. 使用Process子类创建进程

    #_author:来童星#date:2019/12/17# 使用Process子类创建进程from multiprocessing import Processimport timeimport os ...

  9. zjoi 2008 树的统计——树链剖分

    比较基础的一道树链剖分的题 大概还是得说说思路 树链剖分是将树剖成很多条链,比较常见的剖法是按儿子的size来剖分,剖分完后对于这课树的询问用线段树维护——比如求路径和的话——随着他们各自的链向上走, ...

  10. NX二次开发-UF_MODL_ask_angle_tolerance获取建模的角度公差

    NX9+VS2012 #include <uf.h> #include <uf_modl.h> #include <uf_ui.h> UF_initialize() ...