jquery常用代碼實例

$.ajax({ 
url: "test.html", 
context: document.body, 
success: function(){
        $(this).addClass("done");
      }
});
$.ajax({
            type: "get",//使用get方法訪問後臺
            dataType: "json",//返回json格式的數據
            url: "BackHandler.ashx",//要訪問的後臺地址
            data: "pageIndex=" + pageIndex,//要發送的數據
            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+"> More</a>");                    
                    row.attr("id","ready");//改變綁定好數據的行的id
                    row.appendTo("#datas");//添加到模板的容器中
                });


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章