博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jquery之ajax
阅读量:4353 次
发布时间:2019-06-07

本文共 1140 字,大约阅读时间需要 3 分钟。

        $.ajax({
            type: "get",//使用get方法访问后台
            dataType: "json",//返回json格式的数据
            url: "BackHandler.ashx",//要访问的后台地址
            data: "pageIndex=" + pageIndex,//要发送的数据
            beforeSend : function(){ },
            complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
            success: function(msg){//msg为返回的数据,在这里做数据绑定
                var data = msg.table;
                $.each(data, function(i, n){
                    var row = $("#template").clone();
                    row.find("#OrderID").text(n.订单ID);
                    row.find("#CustomerID").text(n.客户ID);
                    row.find("#EmployeeID").text(n.雇员ID);
                    row.find("#OrderDate").text(ChangeDate(n.订购日期));
                    if(n.发货日期!== undefined) row.find("#ShippedDate").text(ChangeDate(n.发货日期));
                    row.find("#ShippedName").text(n.货主名称);
                    row.find("#ShippedAddress").text(n.货主地址);
                    row.find("#ShippedCity").text(n.货主城市);
                    row.find("#more").html("<a href=OrderInfo.aspx?id=" + n.订单ID + "&pageindex="+pageIndex+">&nbsp;More</a>");                   
                    row.attr("id","ready");//改变绑定好数据的行的id
                    row.appendTo("#datas");//添加到模板的容器中
       },
       error: function (XMLHttpRequest, textStatus, errorThrown) {
           // 通常 textStatus 和 errorThrown 之中
           // 只有一个会包含信息
           this; // 调用本次AJAX请求时传递的options参数
      }
  
            });

转载于:https://www.cnblogs.com/andydao/archive/2013/04/28/3049293.html

你可能感兴趣的文章
【讨论】C++程序员是否该掌握某种汇编语言?
查看>>
在iOS上实现变换
查看>>
LeetCode题解之 Implement strStr()
查看>>
Sharepoint List Attachments in a Webpart : The Solution
查看>>
基于组件的游戏对象系统
查看>>
【JS控制图片显示的大小(图片等比例缩放)】
查看>>
五种实用DOM方法总结
查看>>
spring mvc 安全
查看>>
Spring boot 集成Solr
查看>>
.Net互操作2
查看>>
项目中的回车搜索
查看>>
poj 3083 Children of the Candy Corn
查看>>
正则表达式基本语法详解
查看>>
qt 数据库操作总结
查看>>
[ 总结 ] vsftpd 虚拟用户配置
查看>>
win7 解决git clone 连接被拒绝—hosts文件过期
查看>>
properties配置文件的读取和写入
查看>>
最小生成树的Kruskal算法
查看>>
设计模式之-依赖倒置原则
查看>>
luoguP3391[模板]文艺平衡树(Splay) 题解
查看>>