现在的位置: 首页 > 综合 > 正文

Jquery和 LigerUI 用Post\Get\Ajax调用数据前台实例!

2014年08月04日 ⁄ 综合 ⁄ 共 3539字 ⁄ 字号 评论关闭

设置同步参数

 $.ajaxSetup({ async : false});	// 同步参数 false为同步,tree为异步

然后再使用get方法

$.get("register/RegisterState", {test : 12}, function(data, status) {
	if (status == "success") {
            data = eval("(" + data + ")");
	    aDataSet = data;
	    alert("data is " + aDataSet);
	} else {
			alert("wrong");
		 }
});

    // ------------------ 【post】

    $.post

    ("../handle/select.ashx?ajaxaction=GetNum", { FormatId: formatid }, function (data) 

       {

          $("#BoxBottleId").val(data);

       }

    )

        // ------------------ 【LigerUI中的 getJSON】

         $.getJSON

         ('../handle/baseinfo.ashx?ajaxaction=GetClassProductByFid&FatherId=' + currentid,
              function (json) 

              {

                 gridRight.set('data', json); //把json塞到下拉框里面去  

              }
         );

 

        // ------------------ 【ajax】

     $.ajax({
            cache: false,
            async: true,
            url:'../handle/baseinfo.ashx?ajaxaction=GetClassProductByFid',     // 后台取
            data: p.data,
            dataType: 'json', type: 'post',

            beforeSend: function () {
                LG.loading = true;
                if (p.beforeSend)
                    p.beforeSend();
                else
                    LG.showLoading(p.loading);
            },
            complete: function () {
                LG.loading = false;
                if (p.complete)
                    p.complete();
                else
                    LG.hideLoading();
            },
            success: function (result) {
                p.success(result);
            },
            error: function (result, b) {

                LG.tip('发现系统错误 <BR>错误码:' + result.status);
            }
        });

url (String) : 请求的HTML页的URL地址。

data (Map) : (可选参数) 发送至服务器的 key/value 数据

 $.ajax({
        cache: false,
        async: true,
        dataType: 'json', type: 'post',
        url: options.url,
        data: {
            view: options.view,
            idfield: options.idfield,
            textfield: options.textfield,
            where: JSON2.stringify(where)
        },
        success: function (data)
        { 
            if (!data || !data.length) return;
            g._changeValue(data[0]['id'], data[0]['text']);
        }
    });

         // ----------------------- 【LigerUI】

          LG.ajax({
              loading: '正在加载数据...',
              url: '../handle/IdBoxKey.ashx?ajaxaction=GetBoxKeyByApplyId&ApplyId=' + applyid,
              success: function (result) {

                  grid1.set('data',result)
    

              },
              error: function (message) {
                  LG.tip(message);
              }
          });

 

 

 

                Data={};
                Data.Card_Id=Card_Id;
                Data.User_Fee = User_Fee;
                Data.ajaxaction = "Add_Fee";

                Data.Add_Fee1 ="ccc";

                Data.User_Num ="bb";

                LG.ajax({
                    loading: '正在保存数据中...',
                    url: "../handle/card.ashx",
                    data: Data,
                    success: function (json) {
                        // alert(JSON2.stringify(json))

                        $("#Text9").val(json.Current_DL)
                        $("#Text10").val(json.Current_Fee)
                        LG.tip("成功,正在打印单据...");

                    },
                    error: function (message) {
                        LG.tip(message);
                    }
                });

 /////////////////////////////////////////////////////////////// 【返回的是数值型的字符,否则出错】

 /////////////////////////////////////////////////////////////// 【返回的是字符,dataType: "text", 】

            

                  LG.ajax({
                      url: "../handle/Fee_Upload_Handle.ashx",
                      loading: '正在更新中...',
                      data: { ajaxaction: "UpDate_Dl" },  // 设置主键对应。
                      success: function (data)
                      {
                          alert(data);
                          LG.showSuccess(data);
                          // LG.showSuccess('更新成功!数据已清空!');
                          f_reload();
                      },
                      error: function (message) {
                          LG.showError(message);
                      }
                  });

抱歉!评论已关闭.