熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

JQuery 獲取json數據$.getJSON方法

2022-06-13   來源: JSP教程 

  前台:

  function SelectProject() { var a = new Array; var r = windowshowModalDialog(SelProjectaspx a "dialogWidth=px; dialogHeight=px; resizable: yes"); if (typeof (r) != undefined) { var arr = rsplit(";"); $("#hidProjectInnerID")val(arr[]); $("#txtProjectNo")val(arr[]); $getJSON("/Handler/GetProjectInforashx" { key: "PaymentStatement" InnerID: $("#hidProjectInnerID")val() } function (json) { $("#labFinalCustomer")text(jsonfinalclient); $("#labOrderNo")text(jsonorderno); var strDeviceTr = ""; $each(jsonworkinghours function (i item) { strDeviceTr += "<tr><td><lable name="infor"> " + itemdescription + "</lable> </td>"; strDeviceTr += "<td>   </td>"; strDeviceTr += " <td><lable name="infor"> " + itemhoursdays + "</lable></td>"; strDeviceTr += "<td> </td>"; strDeviceTr += "<td><lable name="infor"> " + itemworkinghour + " </lable></td>"; strDeviceTr += "<td> </td>"; strDeviceTr += "<td><lable name="infor"> " + itemworkinghour + "</lable></td>"; strDeviceTr += "<td>  </td>"; strDeviceTr += "</tr>"; }); $("#infor")append(strDeviceTr); }); } }

  ashx

  string innerid = CommonClassRequestGetRequest<string>("InnerID" ""); string key = CommonClassRequestGetRequest<string>("key" ""); string result = ""; if (key == "StockOutApp" && innerid != "") { result = StockOutApp(innerid); contextResponseWrite(result); } else if (key == "PaymentStatement" && innerid != "") { result = PaymentStatement(innerid); contextResponseWrite(result); } #region 結算單信息 public string PaymentStatement(string _innerid) { try { string sql = @"select InnerIDpFinalClientpOrderNo from se_ProjectMain where InnerID=" + _innerid + ""; DataTable dt = SqlShiftGetDataTable(sql); if (!CommonClassDTRowCheckDtIsEmpty(dt)) { StringBuilder json = new StringBuilder(); jsonAppend(""innerid":""+dtRows[]["InnerID"]ToString()+"""); jsonAppend(""finalclient":"" + dtRows[]["pFinalClient"]ToString() + """); jsonAppend(""orderno":"" + dtRows[]["pOrderNo"]ToString() + """); jsonAppend(""workinghours":" + GetWorkingHours(_innerid)); return "{" + jsonToString()Trim() + "}"; } else { return stringEmpty; } } catch (Exception ex) { AppLogWrite("項目獲取異常![異常信息" + exMessage + "]" AppLogLogMessageTypeInfo); return stringEmpty; } } public string GetWorkingHours(string _innerid) { try { string sql = @"select InnerID wDescriptionwWorkingHourwHours_Days from se_ProjectWorkingHour where wProjectID=" + _innerid + ""; DataTable dt = SqlShiftGetDataTable(sql); if (!CommonClassDTRowCheckDtIsEmpty(dt)) { StringBuilder json = new StringBuilder(); for (int i = ; i < dtRowsCount; i++) { jsonAppend("{"); jsonAppend(""innerid":"" + dtRows[]["InnerID"]ToString() + """); jsonAppend(""description":"" + dtRows[]["wDescription"]ToString() + """); jsonAppend(""workinghour":"" + dtRows[]["wWorkingHour"]ToString() + """); jsonAppend(""hoursdays":"" + dtRows[]["wHours_Days"]ToString() + """); jsonAppend("}"); } return "[" + jsonToString()Trim() + "]"; } else { return stringEmpty; } } catch (Exception ex) { AppLogWrite("項目獲取異常![異常信息" + exMessage + "]" AppLogLogMessageTypeInfo); return stringEmpty; } } #endregion

   
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20233.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.