• JQuery 获取json数据$.getJSON方法的实例代码


    这篇文章介绍了JQuery 获取json数据$.getJSON方法的实例代码,有需要的朋友可以参考一下


    前台:

    function SelectProject() {
    
    var a = new Array;
    var r = window.showModalDialog('SelProject.aspx', a, "dialogWidth=1000px; dialogHeight=600px; resizable: yes");
    if (typeof (r) != 'undefined') {
    var arr = r.split(";");
    $("#hidProjectInnerID").val(arr[0]);
    $("#txtProjectNo").val(arr[1]);
    $.getJSON("../Handler/GetProjectInfor.ashx", { key: "PaymentStatement", InnerID: $("#hidProjectInnerID").val() },
    function (json) {
    $("#labFinalCustomer").text(json.finalclient);
    $("#labOrderNo").text(json.orderno);
    var strDeviceTr = "";
    $.each(json.workinghours, function (i, item) {
    strDeviceTr += "<tr><td><lable name="infor"> " + item.description + "</lable> </td>";
    strDeviceTr += "<td> </td>";
    strDeviceTr += " <td><lable name="infor"> " + item.hoursdays + "</lable></td>";
    strDeviceTr += "<td> 0.8</td>";
    strDeviceTr += "<td><lable name="infor"> " + item.workinghour + " </lable></td>";
    strDeviceTr += "<td> 0.8</td>";
    strDeviceTr += "<td><lable name="infor"> " + item.workinghour + "</lable></td>";
    strDeviceTr += "<td> </td>";
    strDeviceTr += "</tr>";
    });
    $("#infor").append(strDeviceTr);
    });
    }
    }

    ashx

    string innerid = CommonClass.Request.GetRequest<string>("InnerID", "");
    string key = CommonClass.Request.GetRequest<string>("key", "");
    string result = "";
    if (key == "StockOutApp" && innerid != "")
    {
    result = StockOutApp(innerid);
    context.Response.Write(result);
    }
    else if (key == "PaymentStatement" && innerid != "")
    {
    result = PaymentStatement(innerid);
    context.Response.Write(result);
    }
    #region 结算单信息
    public string PaymentStatement(string _innerid)
    {
    try
    {
    string sql = @"select InnerID,pFinalClient,pOrderNo from se_ProjectMain where InnerID='" + _innerid + "'";
    DataTable dt = SqlShift.GetDataTable(sql);
    if (!CommonClass.DTRow.CheckDtIsEmpty(dt))
    {
    StringBuilder json = new StringBuilder();
    json.Append(""innerid":""+dt.Rows[0]["InnerID"].ToString()+""");
    json.Append(","finalclient":"" + dt.Rows[0]["pFinalClient"].ToString() + """);
    json.Append(","orderno":"" + dt.Rows[0]["pOrderNo"].ToString() + """);
    json.Append(","workinghours":" + GetWorkingHours(_innerid));
    return "{" + json.ToString().Trim(',') + "}";
    }
    else
    {
    return string.Empty;
    }
    }
    catch (Exception ex)
    {
    AppLog.Write("项目获取异常![异常信息:" + ex.Message + "]", AppLog.LogMessageType.Info);
    return string.Empty;
    }
    }
    public string GetWorkingHours(string _innerid)
    {
    try
    {
    string sql = @"select InnerID, wDescription,wWorkingHour,wHours_Days from se_ProjectWorkingHour where wProjectID='" + _innerid + "'";
    DataTable dt = SqlShift.GetDataTable(sql);
    if (!CommonClass.DTRow.CheckDtIsEmpty(dt))
    {
    StringBuilder json = new StringBuilder();
    for (int i = 0; i < dt.Rows.Count; i++)
    {
    json.Append("{");
    json.Append(""innerid":"" + dt.Rows[0]["InnerID"].ToString() + """);
    json.Append(","description":"" + dt.Rows[0]["wDescription"].ToString() + """);
    json.Append(","workinghour":"" + dt.Rows[0]["wWorkingHour"].ToString() + """);
    json.Append(","hoursdays":"" + dt.Rows[0]["wHours_Days"].ToString() + """);
    json.Append("},");
    }
    return "[" + json.ToString().Trim(',') + "]";
    }
    else
    {
    return string.Empty;
    }
    }
    catch (Exception ex)
    {
    AppLog.Write("项目获取异常![异常信息:" + ex.Message + "]", AppLog.LogMessageType.Info);
    return string.Empty;
    }
    }
    #endregion 
  • 相关阅读:
    常见的问题系列【什么是子网掩码?】
    K8s系列【KubeSphere多租户账号创建流程】
    K8s系列【卸载K8s】
    K8s系列【Linux多节点部署KubeSphere】
    K8s系列【KubeSphere部署完mysql8.0再部署mysql5.0导致mysql5.0启动失败的问题】
    K8s系列【安装nfs文件系统(为k8s提供动态创建pv的能力)】
    K8s系列【Linux单节点部署KubeSphere】
    K8s系列【资源不足:0/3 nodes are available: 1 Insufficient cpu, 2 node(s) had taint {noderole.kubernetes.io/master: }, that the pod didn't tolerate】
    K8s系列【KubeSphere部署Mysql】
    idea格式化快捷键无效
  • 原文地址:https://www.cnblogs.com/study100/p/3232347.html
Copyright © 2020-2023  润新知