JQuery 擷取json資料[$.getJSON方法]

來源:互聯網
上載者:User

前台:[javascript]  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:[csharp]  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    

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.