【问题标题】:how to get JSON array object into Bootstrap table?如何将 JSON 数组对象放入 Bootstrap 表?
【发布时间】:2020-10-20 13:32:52
【问题描述】:

我有一个 JSON 文件,我应该在引导表中获得输出。我的 JSON 文件是这样的:

//your response
var data = {
  "data": [{
      "eventInfo": {
        "context": {
          "siteTimezone": "Asia/Brunei",
          "entityPk": "8802089762861",
          "entityClass": "de.hybris.platform.core.model.order.OrderModel",
          "com.amway.core.events.model.AmwayEventQueueEntryModel": "8805563195834"
        },
        "isoCountryCode": "BN",
        "eventType": "ORDER_CONFIRMED",
        "entityType": "salesorder",
        "sourceTimestamp": "2020-06-25T14:05:56.683+08:00",
        "sourceApplication": "HYBRIS",
        "affiliateCode": "100",
        "entityId": "7100029639",
        "sourceEventId": "4521231e-c347-459b-8d46-43cd2010c8c1",
        "accountId": "8055817",
        "sourceHost": "ip-10-127-165-135.ap-southeast-1.compute.internal"
      },
      "entity": {
        "lynxIsPCP": false,
        "paymentRequired": true,
        "bonusTransactionRequired": true,
        "addresses": [{
            "telephoneNumber": "03-7946 2800",
            "isoCountryCode": "BN",
            "line3": "Bandar Seri Begawan",
            "cityName": "Brunei",
            "line2": "Kampung Kiulap",
            "line1": "6 & 7, Block A, Kompleks Shakirin",
            "careOfName": "",
            "state": "BR",
            "emailAddress": "vhwzezgj@rzrcy.bmh",
            "postalCode": "BE1518",
            "id": "8804188225559"
          },
          {
            "telephoneNumber": "5494492",
            "isoCountryCode": "BN",
            "line3": "GADONG",
            "line4": "8171571",
            "cityName": "BDR SERI BEGAWAN",
            "line2": "KAMPONG RIMBA",
            "line1": "5 SIMPANG 12-32",
            "careOfName": "",
            "state": "BR",
            "emailAddress": "vhwzezgj@rzrcy.bmh",
            "postalCode": "BE3119",
            "id": "8802223521815"
          },
          {
            "telephoneNumber": "5494492",
            "isoCountryCode": "BN",
            "line3": "GADONG",
            "line4": "8171571",
            "cityName": "BDR SERI BEGAWAN",
            "line2": "KAMPONG RIMBA",
            "line1": "5 SIMPANG 12-32",
            "careOfName": "",
            "state": "BR",
            "emailAddress": "vhwzezgj@rzrcy.bmh",
            "postalCode": "BE3119",
            "id": "8802223521815"
          },
          {
            "telephoneNumber": "03-7946 2800",
            "isoCountryCode": "BN",
            "line3": "Bandar Seri Begawan",
            "cityName": "Brunei",
            "line2": "Kampung Kiulap",
            "line1": "6 & 7, Block A, Kompleks Shakirin",
            "careOfName": "",
            "state": "BR",
            "emailAddress": "myhelpdesk@Amway.com",
            "postalCode": "BE1518",
            "id": "8800157073431"
          }
        ],
        "totalOrderValue": 147.5,
        "lynxPaymentChangePaid": 0.0,
        "lynxIsRepair": false,
        "adjustments": [],
        "requestedDeliveryServiceLevel": "walkin",
        "lynxTenure": 0,
        "saleCountryCode": "BN",
        "orderDateTime": "2020-06-25T14:05:56.328+08:00",
        "invoiceSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "userAgent": "Suresh Mathiarasu",
        "orderStatus": "CONFIRMED",
        "isoCurrencyCode": "BND",
        "fees": [{
          "feeCode": "walkin",
          "feeTaxTotalAmount": 0.0,
          "lynxRefunded": false,
          "feeAmount": 0.0,
          "feeTaxDetails": [{
            "taxAmount": 0.0,
            "taxCode": "BN_NO_SCOPE_VAT_SALES"
          }]
        }],
        "bonusPeriod": "202006",
        "orderingPartyId": "40986385",
        "lynxPayerPartyId": "40986385",
        "salesChannelCode": "Point of Sale",
        "lynxIsEpp": false,
        "lynxPayerPartyName": "ROHANA BINTI HJ LATIP",
        "lynxDemandLocationName": "BN",
        "lynxDeliveryType": "pis",
        "paymentSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "orderPriceList": "AmwayDefaultABOPriceGroup",
        "lynxVolumePartyId": "40986385",
        "lynxHasSopEntries": false,
        "orderLines": [{
          "linePrice": 147.5,
          "itemType": "AmwayVariantProduct",
          "itemBV": 29.5,
          "lynxBirTaxPerUnit": 0.0,
          "lynxInvoiceNumber": "130099000",
          "lynxLineAdjustedPV": 0.0,
          "shippedQuantity": 0,
          "lineStatus": "OPEN",
          "lynxProductSerialNumber": [],
          "lineUnitOfMeasure": "EA",
          "allocatedQuantity": 5,
          "linePVAmount": 95.0,
          "lynxBmCode": [],
          "lastUpdateDate": "2020-06-25T14:05:56.469+08:00",
          "lynxBillingAddressReference": "8802223521815",
          "cancelledQuantity": 0,
          "lynxBaseItemId": "115383D",
          "demandLocation": "T45",
          "backorderedQuantity": 0,
          "taxNotRequired": false,
          "pickupAddressReference": "8804188225559",
          "unallocatedQuantity": 0,
          "pendingQuantity": 5,
          "itemABOPrice": 29.5,
          "lineTaxTotalAmount": 0.0,
          "lynxIsSopLine": false,
          "lynxWasBackorder": false,
          "itemSuggestedRetailPrice": 37.0,
          "lineTotalValue": 147.5,
          "baseItemId": "115383D",
          "lynxMasterCode": [],
          "itemDescription": "ARTISTRY SIGNATURE COLOR Lipstick - Daring Red (06) (3.8g)",
          "lineTaxDetails": [{
            "taxAmount": 0.0,
            "taxCode": "BN_NO_SCOPE_VAT_SALES"
          }],
          "shipAddressReference": "8804188225559",
          "lynxPickupAddressName": "BN",
          "lynxIsSopEntry": false,
          "lynxBirAcknowledgementResetCounter": "1",
          "lynxLineAdjustedBV": 0.0,
          "orderedQuantity": 5,
          "itemListPrice": 29.5,
          "fulfillmentType": "walkin",
          "returnedQuantity": 0,
          "orderLineId": 0,
          "itemPV": 19.0,
          "lineBVAmount": 147.5
        }],
        "lynxFulfillmentAddressReference": "8800157073431",
        "cashierBatchId": "amwaybrunei-AM-BN-BN-T45-MY020394-1593058911313",
        "lynxOrderingPartyName": "ROHANA BINTI HJ LATIP",
        "totalBVAmount": 147.5,
        "lynxVolumeTransactions": [],
        "volumeSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "taxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }],
        "lynxUserType": "AmwayBusinessNature_1",
        "lynxPaymentTenderedAmount": 147.5,
        "lynxVolumePartyName": "ROHANA BINTI HJ LATIP",
        "lynxOrderCreatedBy": "MY020394",
        "lynxOms": "Hybris",
        "orderForSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "lynxPaymentInstalmentType": "PIF",
        "lynxMemberPoints": 0.0,
        "lynxContactPhone": "5494492",
        "totalPVAmount": 95.0,
        "inventoryTransactionRequired": true,
        "lynxIsEventBooking": false,
        "lynxBirCashierId": "MY020394",
        "refunds": [],
        "invoiceWithConsignmentRequired": false,
        "orderPeriod": "202006",
        "orderingSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "lynxContactEmailId": "vhwzezgj@rzrcy.bmh",
        "amwaySalesEntity": "780",
        "paymentStatus": "PAID",
        "storefront": "amwaybrunei",
        "lynxPaymentType": "PIF",
        "salesOrderId": "7100029639",
        "lynxOrderCategory": "selfOrder",
        "payments": [{
          "verificationDate": "2020-06-25T14:05:54.453+08:00",
          "lynxIsConnectedFlow": false,
          "paymentLocation": "T45",
          "lynxPaymentProcessedBy": "8055817",
          "paymentStatus": "ACCEPTED",
          "terminalId": "MY020394",
          "paymentReferenceId": "TXN-1593065154321",
          "payerSalesAccount": {
            "accountId": "8055817",
            "lynxPinLevel": "330",
            "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
            "affiliateCode": "100"
          },
          "paymentDate": "2020-06-25T14:05:54.456+08:00",
          "isoCurrencyCode": "BND",
          "lynxPaymentInformation": "",
          "paymentId": "831122002_4e7c1945-b49d-4c86-a0b8-a05b0cb805fa",
          "paymentValue": 147.5,
          "paymentMethod": "cash",
          "merchantId": "amway"
        }],
        "shipToSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "totalABORetailProfit": 0.0,
        "totalTaxAmount": 0.0,
        "lynxOrderType": "NORMAL_ORDER",
        "lynxComments": []
      }
    }


  ]
};
var order_data = ''
//looping under data->data
$.each(data.data, function(key, value) {

  order_data += '<tr>';
  //getting values 
  order_data += '<td>' + value.eventInfo.accountId + '</td>';
  order_data += '<td>' + value.entity.salesOrderId + '</td>';
  order_data += '<td>' + value.eventInfo.eventType + '</td>';
  order_data += '<td>' + value.entity.orderDateTime + '</td>';
  order_data += '<td>' + value.entity.orderStatus + '</td>';
  order_data += '<td>' + value.entity.totalPVAmount + '</td>';
  order_data += '<td>' + value.entity.totalBVAmount + '</td>';
  order_data += '<td>' + value.entity.totalOrderValue + '</td>';
  order_data += '</tr>';

})

$('#order_table>tbody').append(order_data);

我写了一个这样的程序来得到结果。在每个标题下。

例如。在 ABO 标头下,我应该从 entity.orderingSalesAccount.accountId(在 JSON 文件中)获取数据。

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
  <meta name="generator" content="Jekyll v4.0.1">
  <title>Amway Order Entry</title>

  <link rel="canonical" href="https://getbootstrap.com/docs/4.5/examples/checkout/">

  <!-- Bootstrap core CSS -->
  <link href="assets/dist/css/bootstrap.css" rel="stylesheet">

  <!-- Custom styles for this template -->
  <link href="form-validation.css" rel="stylesheet">
  <style>
    .inline-button {
      width: 48%;
      display: inline;
      margin-top: 32px;
    }
  </style>
</head>

<body class="bg-light">
  <div class="container-fluid px-5">

    <div class="row">
      <div class="col-12 mt-5">
        <h4 class="mb-3">Order Enquiry</h4>
        <form class="needs-validation" novalidate>

          <div class="row">
            <div class="col-2">
              <label for="firstName">Country</label>
              <select class="form-control" id="country" >
                <option value="">Choose</option>
                <option value="IN">Malaysia</option>
                <option value="US">Vietnam</option>
                <option value="US">Philippines</option>
                <option value="US">Japan</option>
              </select>
              <div class="invalid-feedback">
                Valid country required.
              </div>
            </div>

            <div class="col-2">
              <label for="firstName">Order Type</label>
              <select class="form-control" id="country" >
                <option value="">Choose</option>
                <option value="IN">Sales Order</option>
                <option value="US">Sales Return</option>
              </select>
              
            </div>


          <div class="col-2">
              <label for="lastName">Order No.</label>
              <input type="text" class="form-control" id="order" placeholder="" value="" >
              <div class="invalid-feedback">
                Valid Order No. is required.
              </div>
          </div>
          <div class="col-2">
              <label for="lastName">From Date</label>
              <input type="date" class="form-control" id="from-date" placeholder="" value="" >
              <div class="invalid-feedback">
                Valid From Date is required.
              </div>
          </div>

            <div class="col-2">
              <label for="lastName">To Date</label>
              <input type="date" class="form-control" id="to-date" placeholder="" value="" >
              <div class="invalid-feedback">
                Valid To Date is required.
              </div>
            </div>

            <div class="col-1"> </div>            

            

            <div class="col-2">
              <label for="lastName">ABO NO</label>
              <input type="text" class="form-control" id="abo" placeholder="" value="" >
              <div class="invalid-feedback">
                Valid ABO is required.
              </div>
            </div>

            <div class="col-3">
              <label for="firstName">Account Type</label>
              <select class="form-control" id="account" >
                <option value="">Choose</option>
                <option value="PSA">Payment Sales Account</option>
                <option value="CA">Volume Sales Account</option>
                <option value="CA">Invoice Sales Account</option>
                <option value="CA">Ship to Sales Account</option>
                <option value="CA">Ordering Sales Account</option>
                <option value="CA">Order to Sales Account</option>
              </select>
              <div class="invalid-feedback">
                Valid Account Type required.
              </div>
            </div>

            <div class="col-0"></div>

            

            <div class="col-2">
              <button class="btn btn-primary inline-button" type="submit">Search</button>
              <button class="btn btn-secondary inline-button" type="reset">Reset</button>
            </div>

            <div class="col-5"></div>

            <p> </p>
          <hr class="mb-4">

          <div class="container-fluid">
  

            <h4>Results :</h4>
             
            <table class="table table-striped" id="order_table">
               <thead>
                  <tr>
                        <th>ABONumber</th>
                        <th>OrderNumber</th>
                        <th>OrderType</th>
                        <th>OrderDate</th>
                        <th>OrderStatus</th>
                        <th>TotalPV</th>
                        <th>TotalBV</th>
                        <th>TotalAmount</th>
                  </tr>
                </thead>
                <tbody></tbody>
    
              </table>
          </div>
    </div>

  </div>
</form>
</div>
</div>
</div>
</body>

     <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
    integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
    crossorigin="anonymous"></script>
    
  <script>window.jQuery || document.write('<script src="../assets/js/vendor/jquery.slim.min.js"><\/script>')</script>
  
  <script src="form-validation.js"></script>
  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />


 
</html>

如何在特定的 Bootstrap 表中获取每个对象的详细信息?任何提示或帮助将不胜感激。自从最近几天以来,我一直坚持这一点。

【问题讨论】:

标签: javascript html jquery ajax twitter-bootstrap


【解决方案1】:

每当我使用表格和引导程序时,我都会使用此资源来处理数据

https://bootstrap-table.com/

顺便说一句,您正在将您的身体数据直接解析到您的表格中,而不是您的 tbody 标记中。 试试这个

$('#order_table>tbody').append(order_data);
//use it in your script-tag

<script>
  $(document).ready(function(){
      $.getJSON("Order.json",function(data){
          var order_data='';
          $.each(data,function(key,value){
              order_data +='<tr>';
              order_data += '<td>'+value.ABONumber+ '</td>';
              order_data += '<td>'+value.OrderNumber+ '</td>';
              order_data += '<td>'+value.OrderType+ '</td>';
              order_data += '<td>'+value.OrderDate+ '</td>';
              order_data += '<td>'+value.OrderStatus+ '</td>';
              order_data += '<td>'+value.TotalPV+ '</td>';
              order_data += '<td>'+value.TotalBV+ '</td>';
              order_data += '<td>'+value.TotalAmount+ '</td>';
              order_data += '</tr>';

          })

          // change this selector!
          $('#order_table>tbody').append(order_data);

      });  

  });
</script>

【讨论】:

  • 感谢分享 Bootstrap 表链接。我以前研究过,但我有点困惑如何使用它?还有你提供的代码,我在哪里用呢?
  • 谢谢@Lukas。不幸的是,我仍然只得到标题。不是价值观
  • @binu456m 我做了一些调试,发现你从数据对象读取数据的方式是错误的。首先,您的数据对象没有这些键,并且您无法获取值的值 :) 试试这个:删除 AOBNumber、Ordernumber 等并仅使用值来了解您的数据对象
  • 我已更改代码(已编辑),但仍未得到结果。我只能看到表格标题
  • 您更改了代码,但没有更改数据变量。使用var order_data=''; $.each(data.data,function(key,value){
【解决方案2】:

你需要遍历data.data然后使用value.eventInfo.accountId来获取accountId等等。

演示代码

//your response
var data = {
  "data": [{
      "eventInfo": {
        "context": {
          "siteTimezone": "Asia/Brunei",
          "entityPk": "8802089762861",
          "entityClass": "de.hybris.platform.core.model.order.OrderModel",
          "com.amway.core.events.model.AmwayEventQueueEntryModel": "8805563195834"
        },
        "isoCountryCode": "BN",
        "eventType": "ORDER_CONFIRMED",
        "entityType": "salesorder",
        "sourceTimestamp": "2020-06-25T14:05:56.683+08:00",
        "sourceApplication": "HYBRIS",
        "affiliateCode": "100",
        "entityId": "7100029639",
        "sourceEventId": "4521231e-c347-459b-8d46-43cd2010c8c1",
        "accountId": "8055817",
        "sourceHost": "ip-10-127-165-135.ap-southeast-1.compute.internal"
      },
      "entity": {
        "lynxIsPCP": false,
        "paymentRequired": true,
        "bonusTransactionRequired": true,
        "addresses": [{
            "telephoneNumber": "03-7946 2800",
            "isoCountryCode": "BN",
            "line3": "Bandar Seri Begawan",
            "cityName": "Brunei",
            "line2": "Kampung Kiulap",
            "line1": "6 & 7, Block A, Kompleks Shakirin",
            "careOfName": "",
            "state": "BR",
            "emailAddress": "vhwzezgj@rzrcy.bmh",
            "postalCode": "BE1518",
            "id": "8804188225559"
          },
          {
            "telephoneNumber": "5494492",
            "isoCountryCode": "BN",
            "line3": "GADONG",
            "line4": "8171571",
            "cityName": "BDR SERI BEGAWAN",
            "line2": "KAMPONG RIMBA",
            "line1": "5 SIMPANG 12-32",
            "careOfName": "",
            "state": "BR",
            "emailAddress": "vhwzezgj@rzrcy.bmh",
            "postalCode": "BE3119",
            "id": "8802223521815"
          },
          {
            "telephoneNumber": "5494492",
            "isoCountryCode": "BN",
            "line3": "GADONG",
            "line4": "8171571",
            "cityName": "BDR SERI BEGAWAN",
            "line2": "KAMPONG RIMBA",
            "line1": "5 SIMPANG 12-32",
            "careOfName": "",
            "state": "BR",
            "emailAddress": "vhwzezgj@rzrcy.bmh",
            "postalCode": "BE3119",
            "id": "8802223521815"
          },
          {
            "telephoneNumber": "03-7946 2800",
            "isoCountryCode": "BN",
            "line3": "Bandar Seri Begawan",
            "cityName": "Brunei",
            "line2": "Kampung Kiulap",
            "line1": "6 & 7, Block A, Kompleks Shakirin",
            "careOfName": "",
            "state": "BR",
            "emailAddress": "myhelpdesk@Amway.com",
            "postalCode": "BE1518",
            "id": "8800157073431"
          }
        ],
        "totalOrderValue": 147.5,
        "lynxPaymentChangePaid": 0.0,
        "lynxIsRepair": false,
        "adjustments": [],
        "requestedDeliveryServiceLevel": "walkin",
        "lynxTenure": 0,
        "saleCountryCode": "BN",
        "orderDateTime": "2020-06-25T14:05:56.328+08:00",
        "invoiceSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "userAgent": "Suresh Mathiarasu",
        "orderStatus": "CONFIRMED",
        "isoCurrencyCode": "BND",
        "fees": [{
          "feeCode": "walkin",
          "feeTaxTotalAmount": 0.0,
          "lynxRefunded": false,
          "feeAmount": 0.0,
          "feeTaxDetails": [{
            "taxAmount": 0.0,
            "taxCode": "BN_NO_SCOPE_VAT_SALES"
          }]
        }],
        "bonusPeriod": "202006",
        "orderingPartyId": "40986385",
        "lynxPayerPartyId": "40986385",
        "salesChannelCode": "Point of Sale",
        "lynxIsEpp": false,
        "lynxPayerPartyName": "ROHANA BINTI HJ LATIP",
        "lynxDemandLocationName": "BN",
        "lynxDeliveryType": "pis",
        "paymentSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "orderPriceList": "AmwayDefaultABOPriceGroup",
        "lynxVolumePartyId": "40986385",
        "lynxHasSopEntries": false,
        "orderLines": [{
          "linePrice": 147.5,
          "itemType": "AmwayVariantProduct",
          "itemBV": 29.5,
          "lynxBirTaxPerUnit": 0.0,
          "lynxInvoiceNumber": "130099000",
          "lynxLineAdjustedPV": 0.0,
          "shippedQuantity": 0,
          "lineStatus": "OPEN",
          "lynxProductSerialNumber": [],
          "lineUnitOfMeasure": "EA",
          "allocatedQuantity": 5,
          "linePVAmount": 95.0,
          "lynxBmCode": [],
          "lastUpdateDate": "2020-06-25T14:05:56.469+08:00",
          "lynxBillingAddressReference": "8802223521815",
          "cancelledQuantity": 0,
          "lynxBaseItemId": "115383D",
          "demandLocation": "T45",
          "backorderedQuantity": 0,
          "taxNotRequired": false,
          "pickupAddressReference": "8804188225559",
          "unallocatedQuantity": 0,
          "pendingQuantity": 5,
          "itemABOPrice": 29.5,
          "lineTaxTotalAmount": 0.0,
          "lynxIsSopLine": false,
          "lynxWasBackorder": false,
          "itemSuggestedRetailPrice": 37.0,
          "lineTotalValue": 147.5,
          "baseItemId": "115383D",
          "lynxMasterCode": [],
          "itemDescription": "ARTISTRY SIGNATURE COLOR Lipstick - Daring Red (06) (3.8g)",
          "lineTaxDetails": [{
            "taxAmount": 0.0,
            "taxCode": "BN_NO_SCOPE_VAT_SALES"
          }],
          "shipAddressReference": "8804188225559",
          "lynxPickupAddressName": "BN",
          "lynxIsSopEntry": false,
          "lynxBirAcknowledgementResetCounter": "1",
          "lynxLineAdjustedBV": 0.0,
          "orderedQuantity": 5,
          "itemListPrice": 29.5,
          "fulfillmentType": "walkin",
          "returnedQuantity": 0,
          "orderLineId": 0,
          "itemPV": 19.0,
          "lineBVAmount": 147.5
        }],
        "lynxFulfillmentAddressReference": "8800157073431",
        "cashierBatchId": "amwaybrunei-AM-BN-BN-T45-MY020394-1593058911313",
        "lynxOrderingPartyName": "ROHANA BINTI HJ LATIP",
        "totalBVAmount": 147.5,
        "lynxVolumeTransactions": [],
        "volumeSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "taxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }],
        "lynxUserType": "AmwayBusinessNature_1",
        "lynxPaymentTenderedAmount": 147.5,
        "lynxVolumePartyName": "ROHANA BINTI HJ LATIP",
        "lynxOrderCreatedBy": "MY020394",
        "lynxOms": "Hybris",
        "orderForSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "lynxPaymentInstalmentType": "PIF",
        "lynxMemberPoints": 0.0,
        "lynxContactPhone": "5494492",
        "totalPVAmount": 95.0,
        "inventoryTransactionRequired": true,
        "lynxIsEventBooking": false,
        "lynxBirCashierId": "MY020394",
        "refunds": [],
        "invoiceWithConsignmentRequired": false,
        "orderPeriod": "202006",
        "orderingSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "lynxContactEmailId": "vhwzezgj@rzrcy.bmh",
        "amwaySalesEntity": "780",
        "paymentStatus": "PAID",
        "storefront": "amwaybrunei",
        "lynxPaymentType": "PIF",
        "salesOrderId": "7100029639",
        "lynxOrderCategory": "selfOrder",
        "payments": [{
          "verificationDate": "2020-06-25T14:05:54.453+08:00",
          "lynxIsConnectedFlow": false,
          "paymentLocation": "T45",
          "lynxPaymentProcessedBy": "8055817",
          "paymentStatus": "ACCEPTED",
          "terminalId": "MY020394",
          "paymentReferenceId": "TXN-1593065154321",
          "payerSalesAccount": {
            "accountId": "8055817",
            "lynxPinLevel": "330",
            "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
            "affiliateCode": "100"
          },
          "paymentDate": "2020-06-25T14:05:54.456+08:00",
          "isoCurrencyCode": "BND",
          "lynxPaymentInformation": "",
          "paymentId": "831122002_4e7c1945-b49d-4c86-a0b8-a05b0cb805fa",
          "paymentValue": 147.5,
          "paymentMethod": "cash",
          "merchantId": "amway"
        }],
        "shipToSalesAccount": {
          "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "totalABORetailProfit": 0.0,
        "totalTaxAmount": 0.0,
        "lynxOrderType": "NORMAL_ORDER",
        "lynxComments": []
      }
    }


  ]
};
var order_data = ''
//looping under data->data
$.each(data.data, function(key, value) {

  order_data += '<tr>';
  //getting values 
  order_data += '<td>' + value.eventInfo.accountId + '</td>';
  order_data += '<td>' + value.entity.salesOrderId + '</td>';
  order_data += '<td>' + value.eventInfo.eventType + '</td>';
  order_data += '<td>' + value.entity.orderDateTime + '</td>';
  order_data += '<td>' + value.entity.orderStatus + '</td>';
  order_data += '<td>' + value.entity.totalPVAmount + '</td>';
  order_data += '<td>' + value.entity.totalBVAmount + '</td>';
  order_data += '<td>' + value.entity.totalOrderValue + '</td>';
  order_data += '</tr>';

})

$('#order_table>tbody').append(order_data);
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table class="table table-striped" id="order_table">
  <thead>
    <tr>
      <th>ABONumber</th>
      <th>OrderNumber</th>
      <th>OrderType</th>
      <th>OrderDate</th>
      <th>OrderStatus</th>
      <th>TotalPV</th>
      <th>TotalBV</th>
      <th>TotalAmount</th>
    </tr>
  </thead>
  <tbody></tbody>

</table>

【讨论】:

  • 谢谢斯瓦蒂。我已经更新了代码,但仍然没有得到结果
  • 我已经尝试了上面的代码,我得到了网页。但是当我给出命令# 7100029639 然后搜索时,我收到这样的错误:加载资源失败:net::ERR_FILE_NOT_FOUND jquery.min.js:1 加载资源失败:服务器响应状态为 404 ()跨度>
  • 搜索?我在哪里没有找到与此相关的任何代码?
  • 它已经在我问的问题中......代码有它
  • 您收到文件未找到错误?检查您是否正确链接了文件?您的代码添加了4 jQuery cdn and files 吗?请只使用一个cdn。
【解决方案3】:

如果可能的话,可以看看像 lit-html 这样的模板库

那些库的语法正是为此而生的。

[https://lit-html.polymer-project.org/]

我喜欢使用这个你可以在模板中编写的库:

const itemTemplates = [];
for (const i of items) {
  itemTemplates.push(html`<li>${i}</li>`);
}

html`
  <ul>
    ${itemTemplates}
  </ul>
`;

而且它真的很轻,所以加载时间不会明显延长

【讨论】:

    猜你喜欢
    • 2021-08-22
    • 2021-07-18
    • 2014-10-15
    • 2017-07-27
    • 2017-05-13
    • 1970-01-01
    • 2020-09-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多